From 3f8ef290786fbaf7b9ec200a2fd598eb324c6b0c Mon Sep 17 00:00:00 2001 From: Franklin Wei Date: Sun, 21 Jul 2024 04:49:06 -0400 Subject: [PATCH] midend_process_key: allow Shift+Tab to pass through to the backend. Previously, a button code of ('\t' | MOD_SHFT) from a frontend would have the MOD_SHFT flag stripped by midend_process_key, resulting in a bare '\t' passed to the backend. Now, this combination is allowed to pass through to the backend. This will be used in the keyboard interface to Untangle, which I'm about to add. --- devel.but | 6 +++--- midend.c | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/devel.but b/devel.but index 4d205ac..577e74d 100644 --- a/devel.but +++ b/devel.but @@ -1145,9 +1145,9 @@ the \c{button} parameter: \dt \cw{MOD_CTRL}, \cw{MOD_SHFT} -\dd These indicate that the Control or Shift key was pressed -alongside the key. They only apply to the cursor keys, not to mouse -buttons or anything else. +\dd These indicate that the Control or Shift key was pressed alongside +the key. They only apply to the cursor keys and the ASCII horizontal +tab character \cw{\\t}, not to mouse buttons or anything else. \dt \cw{MOD_NUM_KEYPAD} diff --git a/midend.c b/midend.c index 34290cc..bcacfc2 100644 --- a/midend.c +++ b/midend.c @@ -1219,13 +1219,15 @@ int midend_process_key(midend *me, int x, int y, int button) /* Special handling to make CTRL+SHFT+Z into REDO. */ if ((button & (~MOD_MASK | MOD_SHFT)) == (MOD_SHFT | '\x1A')) button = UI_REDO; - /* interpret_move() expects CTRL and SHFT only on cursor keys. */ - if (!IS_CURSOR_MOVE(button & ~MOD_MASK)) { + /* interpret_move() expects CTRL and SHFT only on cursor keys, and + * TAB (added as of 7/2024 to support Untangle). */ + if (!IS_CURSOR_MOVE(STRIP_BUTTON_MODIFIERS(button))) { /* reject CTRL+anything odd */ - if ((button & MOD_CTRL) && (button & ~MOD_MASK) >= 0x20) + if ((button & MOD_CTRL) && STRIP_BUTTON_MODIFIERS(button) >= 0x20) return PKR_UNUSED; - /* otherwise strip them */ - button &= ~(MOD_CTRL | MOD_SHFT); + /* otherwise strip them, except for tab */ + if (STRIP_BUTTON_MODIFIERS(button) != '\t') + button &= ~(MOD_CTRL | MOD_SHFT); } /* interpret_move() expects NUM_KEYPAD only on numbers. */ if ((button & ~MOD_MASK) < '0' || (button & ~MOD_MASK) > '9')