csi: add new private mode that makes the Escape key emit "\E[27;1;27~"

This mode can be set by client programs with the DECSET, DECRST,
XTSAVE and XTRESTORE sequences by using 27127 as the parameter.

The sequence "\E[27;1;27~" is encoded in the same way as is done by
xterm's "modifyOtherKeys" mode. Even though xterm itself never emits
such a sequence for the Escape key, many programs already have
support for parsing this style of key sequence.
This commit is contained in:
Craig Barnes 2020-11-29 04:04:57 +00:00
parent c213ee90f1
commit 31c73f0cf0
4 changed files with 16 additions and 1 deletions

View file

@ -891,7 +891,13 @@ key_press_release(struct seat *seat, struct terminal *term, uint32_t serial,
keymap_mods |= seat->kbd.ctrl ? MOD_CTRL : MOD_NONE;
keymap_mods |= seat->kbd.meta ? MOD_META : MOD_NONE;
const struct key_data *keymap = keymap_lookup(seat, term, sym, keymap_mods);
const struct key_data *keymap;
if (sym == XKB_KEY_Escape && keymap_mods == MOD_NONE && term->modify_escape_key) {
static const struct key_data esc = {.seq = "\033[27;1;27~"};
keymap = &esc;
} else
keymap = keymap_lookup(seat, term, sym, keymap_mods);
if (keymap != NULL) {
term_to_slave(term, keymap->seq, strlen(keymap->seq));