From 6f0bde11ccd82d257fcda25ecad26227eba3335e Mon Sep 17 00:00:00 2001 From: Gregory Anders Date: Wed, 15 Jan 2025 11:07:51 -0600 Subject: feat(terminal): add support for kitty keyboard protocol This commit adds basic support for the kitty keyboard protocol to Neovim's builtin terminal. For now only the first mode ("Disambiguate escape codes") is supported. --- src/nvim/getchar.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/nvim/getchar.c') diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 6cf4556a9f..6ec84ff543 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1517,12 +1517,10 @@ int merge_modifiers(int c_arg, int *modifiers) int c = c_arg; if (*modifiers & MOD_MASK_CTRL) { - if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_')) { - if (!(State & MODE_TERMINAL) || !(c == 'I' || c == 'J' || c == 'M' || c == '[')) { - c &= 0x1f; - if (c == NUL) { - c = K_ZERO; - } + if (c >= '@' && c <= 0x7f) { + c &= 0x1f; + if (c == NUL) { + c = K_ZERO; } } else if (c == '6') { // CTRL-6 is equivalent to CTRL-^ @@ -2058,6 +2056,12 @@ static bool at_ins_compl_key(void) /// @return the length of the replaced bytes, 0 if nothing changed, -1 for error. static int check_simplify_modifier(int max_offset) { + // We want full modifiers in Terminal mode so that the key can be correctly + // encoded + if (State & MODE_TERMINAL) { + return 0; + } + for (int offset = 0; offset < max_offset; offset++) { if (offset + 3 >= typebuf.tb_len) { break; -- cgit