shithub: puzzles

Download patch

ref: 01569005e325fc85e4a23fc050b7406789730444
parent: fe40cda75a9665f7b464fa9909de0a7f62613817
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Mar 5 11:35:41 EST 2023

Further restrict the keys that can have MOD_NUM_KEYPAD

In all front ends other than JavaScript, and in JavaScript prior to my
recent changes, MOD_NUM_KEYPAD can only be set on ASCII digits.  For
now, enforce this in midend_process_key() so as to avoid inconsistency
between front ends.  It might be useful to be able to distinguish
keypad versions of more keys, but that should be co-ordinated across
the code-base.

--- a/midend.c
+++ b/midend.c
@@ -1182,8 +1182,8 @@
     /* interpret_move() expects CTRL and SHFT only on cursor keys. */
     if (!IS_CURSOR_MOVE(button & ~MOD_MASK))
         button &= ~(MOD_CTRL | MOD_SHFT);
-    /* ... and NUM_KEYPAD only on printable ASCII values. */
-    if ((button & ~MOD_MASK) < 0x20 || (button & ~MOD_MASK) >= 0x80)
+    /* ... and NUM_KEYPAD only on numbers. */
+    if ((button & ~MOD_MASK) < '0' || (button & ~MOD_MASK) > '9')
         button &= ~MOD_NUM_KEYPAD;
     /*
      * Translate keyboard presses to cursor selection.