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.
This commit is contained in:
Ben Harris
2023-03-05 16:35:41 +00:00
parent fe40cda75a
commit 01569005e3

View File

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