- {
- const int i = w*ui->y + ui->x;
- char buf[64];
- ui->x = ui->y = -1;
- if (state->board[i] == button) {
- return ""; /* no change - just update ui */
- } else {
- sprintf(buf, "%d_%d", i, button);
- return dupstr(buf);
- }
+ for (i = 0; i < w*h; i++) {
+ char buf[32];
+ if ((ui->sel && ui->sel[i]) ||
+ (!ui->sel && ui->cur_visible && (w*ui->cur_y+ui->cur_x) == i)) {
+ if (state->shared->clues[i] != 0) continue; /* in case cursor is on clue */
+ if (state->board[i] != button) {
+ sprintf(buf, "%s%d", move ? "," : "", i);
+ if (move) {
+ move = srealloc(move, strlen(move)+strlen(buf)+1);
+ strcat(move, buf);
+ } else {
+ move = smalloc(strlen(buf)+1);
+ strcpy(move, buf);
+ }
+ }
+ }
+ }
+ if (move) {
+ char buf[32];
+ sprintf(buf, "_%d", button);
+ move = srealloc(move, strlen(move)+strlen(buf)+1);
+ strcat(move, buf);