shithub: puzzles

Download patch

ref: 79fe68dc57d72d4765850eb9aec23675523a1a4d
parent: 6179e8df56000bc8f558129a8475cf977c06a249
author: Jonas Kölker <jonaskoelker@yahoo.com>
date: Thu Oct 1 14:41:15 EDT 2015

Towers: allow marking of clues as done with the keyboard

--- a/puzzles.but
+++ b/puzzles.but
@@ -2652,7 +2652,8 @@
 that does not have a main digit in it.
 
 Left-clicking a clue will mark it as done (grey it out), or unmark it
-if it is already marked.
+if it is already marked.  Holding Control or Shift and pressing an
+arrow key likewise marks any clue in the given direction.
 
 (All the actions described in \k{common-actions} are also available.)
 
--- a/towers.c
+++ b/towers.c
@@ -1292,6 +1292,7 @@
                             int x, int y, int button)
 {
     int w = state->par.w;
+    int shift_or_control = button & (MOD_SHFT | MOD_CTRL);
     int tx, ty;
     char buf[80];
 
@@ -1376,6 +1377,20 @@
         }
     }
     if (IS_CURSOR_MOVE(button)) {
+        if (shift_or_control) {
+            int x = ui->hx, y = ui->hy;
+            switch (button) {
+            case CURSOR_LEFT:   x = -1; break;
+            case CURSOR_RIGHT:  x =  w; break;
+            case CURSOR_UP:     y = -1; break;
+            case CURSOR_DOWN:   y =  w; break;
+            }
+            if (is_clue(state, x, y)) {
+                sprintf(buf, "%c%d,%d", 'D', x, y);
+                return dupstr(buf);
+            }
+            return NULL;
+        }
         move_cursor(button, &ui->hx, &ui->hy, w, w, 0);
         ui->hshow = ui->hcursor = 1;
         return "";