summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenno Schulenberg <bensberg@telfort.nl>2023-10-16 08:44:25 +0200
committerBenno Schulenberg <bensberg@telfort.nl>2023-10-16 08:55:06 +0200
commitef35ea72cfaada26f6ee1ca3473e1ce78481f6b7 (patch)
treef9b53a4f5a30da1ed10cf8bc40f5a2001dd97fd8
parent8804b6dcd4ac49ad526914418c4db0a59b8e4ba9 (diff)
downloadnano-ef35ea72.tar.gz
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.
-rw-r--r--src/definitions.h3
-rw-r--r--src/global.c1
-rw-r--r--src/nano.c2
-rw-r--r--src/prototypes.h1
-rw-r--r--src/winio.c9
5 files changed, 11 insertions, 5 deletions
diff --git a/src/definitions.h b/src/definitions.h
index 7f0c491..6c94e75 100644
--- 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
index a73f2ef..ce1fe5e 100644
--- 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
index 8578ee7..2ade663 100644
--- 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
index d2b2e1a..5462a5a 100644
--- 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
index 15da064..cfb0c2a 100644
--- 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. */