Revamp extended keys support to more closely match xterm and support

mode 2 as well as mode 1. From Stanislav Kljuhhin (GitHub issue 4038).

This changes tmux to always request mode 2 from parent terminal, change
to an unambiguous internal representation of keys, and adds an option
(extended-keys-format) to control the format similar to the xterm(1)
formatOtherKeys resource.
This commit is contained in:
nicm
2024-08-21 04:17:09 +00:00
parent de6bce057a
commit c7e61a01e5
12 changed files with 238 additions and 136 deletions

View File

@ -107,8 +107,9 @@ screen_reinit(struct screen *s)
s->rlower = screen_size_y(s) - 1;
s->mode = MODE_CURSOR|MODE_WRAP|(s->mode & MODE_CRLF);
if (options_get_number(global_options, "extended-keys") == 2)
s->mode |= MODE_KEXTENDED;
s->mode = (s->mode & ~EXTENDED_KEY_MODES)|MODE_KEYS_EXTENDED;
if (s->saved_grid != NULL)
screen_alternate_off(s, NULL, 0);
@ -714,8 +715,10 @@ screen_mode_to_string(int mode)
strlcat(tmp, "ORIGIN,", sizeof tmp);
if (mode & MODE_CRLF)
strlcat(tmp, "CRLF,", sizeof tmp);
if (mode & MODE_KEXTENDED)
strlcat(tmp, "KEXTENDED,", sizeof tmp);
if (mode & MODE_KEYS_EXTENDED)
strlcat(tmp, "KEYS_EXTENDED,", sizeof tmp);
if (mode & MODE_KEYS_EXTENDED_2)
strlcat(tmp, "KEYS_EXTENDED_2,", sizeof tmp);
tmp[strlen(tmp) - 1] = '\0';
return (tmp);
}