commit ef35ea72cfaada26f6ee1ca3473e1ce78481f6b7
parent 8804b6dcd4ac49ad526914418c4db0a59b8e4ba9
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Mon, 16 Oct 2023 08:44:25 +0200
input: neutralize two spurious keycodes from VTE terminals
At least some of the VTE-based terminals claim to be compatible with
xterm-25color (and set TERM to that value). But they really aren't:
they mishandle the focus-in and focus-out events, for example. So,
catch and discard the corresponding keycodes that nano shouldn't be
seeing at all.
This improves the fix for https://savannah.gnu.org/bugs/?64578.
Diffstat:
5 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/src/definitions.h b/src/definitions.h
@@ -214,6 +214,9 @@
#define SHIFT_DELETE 0x45D
#define SHIFT_TAB 0x45F
+#define FOCUS_IN 0x491
+#define FOCUS_OUT 0x499
+
/* Special keycodes for when a string bind has been partially implanted
* or has an unpaired opening brace, or when a function in a string bind
* needs execution or a specified function name is invalid. */
diff --git a/src/global.c b/src/global.c
@@ -107,6 +107,7 @@ int altpageup, altpagedown;
int altinsert, altdelete;
int shiftaltleft, shiftaltright, shiftaltup, shiftaltdown;
#endif
+int mousefocusin, mousefocusout;
#ifdef ENABLED_WRAPORJUSTIFY
ssize_t fill = -COLUMNS_FROM_EOL;
diff --git a/src/nano.c b/src/nano.c
@@ -2426,6 +2426,8 @@ int main(int argc, char **argv)
shiftaltup = get_keycode("kUP4", SHIFT_ALT_UP);
shiftaltdown = get_keycode("kDN4", SHIFT_ALT_DOWN);
#endif
+ mousefocusin = get_keycode("kxIN", FOCUS_IN);
+ mousefocusout = get_keycode("kxOUT", FOCUS_OUT);
#ifdef HAVE_SET_ESCDELAY
/* Tell ncurses to pass the Esc key quickly. */
diff --git a/src/prototypes.h b/src/prototypes.h
@@ -80,6 +80,7 @@ extern int altinsert, altdelete;
extern int shiftaltleft, shiftaltright;
extern int shiftaltup, shiftaltdown;
#endif
+extern int mousefocusin, mousefocusout;
#ifdef ENABLED_WRAPORJUSTIFY
extern ssize_t fill;
diff --git a/src/winio.c b/src/winio.c
@@ -1245,6 +1245,10 @@ int parse_kbinput(WINDOW *frame)
return INDENT_KEY;
#endif
+ /* Spurious codes from VTE -- see https://sv.gnu.org/bugs/?64578. */
+ if (keycode == mousefocusin || keycode == mousefocusout)
+ return ERR;
+
switch (keycode) {
case KEY_SLEFT:
shift_held = TRUE;
@@ -1320,11 +1324,6 @@ int parse_kbinput(WINDOW *frame)
case KEY_BTAB:
return SHIFT_TAB;
- case 0x24C: /* Spurious code from VTE -- see https://sv.gnu.org/bugs/?64578. */
- statusline(ALERT, _("Wrong TERM for this terminal"));
- place_the_cursor();
- return ERR;
-
case KEY_SBEG:
case KEY_BEG:
case KEY_B2: /* Center (5) on keypad with NumLock off. */