input: provide for urxvt setting a high bit or sending an extra escape

When pressing Alt+Home/Alt+End on urxvt, urxvt either sets the high bit
of the last byte in the sequence for Home/End (when Meta8 is True), or
sends an extra escape before that same sequence (when Meta8 is False).
Accommodate for this bug by recognizing the produced code sequences.

Indirectly-reported-by: Sébastien Desreux <seb@h-k.fr>
  https://lists.gnu.org/archive/html/nano-devel/2024-05/msg00007.html
This commit is contained in:
Benno Schulenberg 2024-05-11 12:04:04 +02:00
parent f70f528730
commit 363a4378b7

View File

@ -825,6 +825,8 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
#ifndef NANO_TINY
else if (length > 1 && seq[1] == '@')
return shiftcontrolhome;
else if (length > 1 && seq[1] == 0xFE)
return ALT_HOME;
#endif
break;
case '8': /* Esc [ 8 ~ == End on Eterm/rxvt;
@ -840,6 +842,8 @@ int convert_CSI_sequence(const int *seq, size_t length, int *consumed)
#ifndef NANO_TINY
else if (length > 1 && seq[1] == '@')
return shiftcontrolend;
else if (length > 1 && seq[1] == 0xFE)
return ALT_END;
#endif
break;
case '9': /* Esc [ 9 == Delete on Mach console. */
@ -1052,6 +1056,12 @@ int parse_kbinput(WINDOW *frame)
#endif
else if (keycode < 0x20 && !last_escape_was_alone)
meta_key = TRUE;
#ifndef NANO_TINY
else if (keycode == KEY_HOME)
return ALT_HOME;
else if (keycode == KEY_END)
return ALT_END;
#endif
} else if (waiting_codes == 0 || nextcodes[0] == ESC_CODE ||
(keycode != 'O' && keycode != '[')) {
if (!shifted_metas)