shithub: puzzles

Download patch

ref: f8c2477ccbe2e86af2dba2c8483b7655d06652ec
parent: 568c22210611f369e11b9348a6e1145bba9c6ee7
author: Ben Harris <[email protected]>
date: Sat Aug 12 09:34:40 EDT 2023

Twiddle: use move_cursor() for cursor movement

--- a/twiddle.c
+++ b/twiddle.c
@@ -666,18 +666,9 @@
 
     button = button & (~MOD_MASK | MOD_NUM_KEYPAD);
 
-    if (IS_CURSOR_MOVE(button)) {
-        if (button == CURSOR_LEFT && ui->cur_x > 0)
-            ui->cur_x--;
-        if (button == CURSOR_RIGHT && (ui->cur_x+n) < (w))
-            ui->cur_x++;
-        if (button == CURSOR_UP && ui->cur_y > 0)
-            ui->cur_y--;
-        if (button == CURSOR_DOWN && (ui->cur_y+n) < (h))
-            ui->cur_y++;
-        ui->cur_visible = true;
-        return MOVE_UI_UPDATE;
-    }
+    if (IS_CURSOR_MOVE(button))
+        return move_cursor(button, &ui->cur_x, &ui->cur_y, w-n+1, h-n+1,
+                           false, &ui->cur_visible);
 
     if (button == LEFT_BUTTON || button == RIGHT_BUTTON) {
 	/*