From 01569005e325fc85e4a23fc050b7406789730444 Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Sun, 5 Mar 2023 16:35:41 +0000 Subject: [PATCH] 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. --- midend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/midend.c b/midend.c index 72330b7..e66d15a 100644 --- a/midend.c +++ b/midend.c @@ -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. */ 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.