chiark / gitweb /
Fix a memory error in Guess cursor handling.
[sgt-puzzles.git] / pearl.c
diff --git a/pearl.c b/pearl.c
index ff1296449f56b9673da1a299a09b9a9916182a3e..977577f55bb1d78bf9b05ad9e33b36fc1b77498b 100644 (file)
--- a/pearl.c
+++ b/pearl.c
@@ -2024,10 +2024,14 @@ static char *interpret_move(const game_state *state, game_ui *ui,
        if (!ui->cursor_active) {
            ui->cursor_active = TRUE;
        } else if (control | shift) {
+           char *move;
            if (ui->ndragcoords > 0) return NULL;
            ui->ndragcoords = -1;
-           return mark_in_direction(state, ui->curx, ui->cury,
+           move = mark_in_direction(state, ui->curx, ui->cury,
                                     KEY_DIRECTION(button), control, tmpbuf);
+           if (control && !shift && *move)
+               move_cursor(button, &ui->curx, &ui->cury, w, h, FALSE);
+           return move;
        } else {
            move_cursor(button, &ui->curx, &ui->cury, w, h, FALSE);
            if (ui->ndragcoords >= 0)
@@ -2054,6 +2058,11 @@ static char *interpret_move(const game_state *state, game_ui *ui,
        }
     }
 
+    if (button == 27 || button == '\b') {
+        ui->ndragcoords = -1;
+        return "";
+    }
+
     if (release) {
         if (ui->ndragcoords > 0) {
             /* End of a drag: process the cached line data. */