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.
This commit is contained in:
Benno Schulenberg 2023-10-16 08:44:25 +02:00
parent 8804b6dcd4
commit ef35ea72cf
5 changed files with 11 additions and 5 deletions

View File

@ -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. */

View File

@ -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;

View File

@ -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. */

View File

@ -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;

View File

@ -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. */