+ if (IS_CURSOR_MOVE(button)) {
+ move_cursor(button, &ui->cur_x, &ui->cur_y, state->w, state->h, 0);
+ ui->cur_visible = 1;
+ return "";
+ }
+ if (IS_CURSOR_SELECT(button)) {
+ int currstate = state->grid[ui->cur_y * state->w + ui->cur_x];
+ int newstate;
+ char buf[80];
+
+ if (!ui->cur_visible) {
+ ui->cur_visible = 1;
+ return "";
+ }
+
+ if (button == CURSOR_SELECT2)
+ newstate = currstate == GRID_UNKNOWN ? GRID_EMPTY :
+ currstate == GRID_EMPTY ? GRID_FULL : GRID_UNKNOWN;
+ else
+ newstate = currstate == GRID_UNKNOWN ? GRID_FULL :
+ currstate == GRID_FULL ? GRID_EMPTY : GRID_UNKNOWN;
+
+ sprintf(buf, "%c%d,%d,%d,%d",
+ (char)(newstate == GRID_FULL ? 'F' :
+ newstate == GRID_EMPTY ? 'E' : 'U'),
+ ui->cur_x, ui->cur_y, 1, 1);
+ return dupstr(buf);
+ }
+