Mercurial > vim
diff src/terminal.c @ 31192:dcde141f2d1e v9.0.0930
patch 9.0.0930: cannot debug the Kitty keyboard protocol with TermDebug
Commit: https://github.com/vim/vim/commit/63a2e360cca2c70ab0a85d14771d3259d4b3aafa
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Nov 23 20:20:18 2022 +0000
patch 9.0.0930: cannot debug the Kitty keyboard protocol with TermDebug
Problem: Cannot debug the Kitty keyboard protocol with TermDebug.
Solution: Add Kitty keyboard protocol support to the libvterm fork.
Recognize the escape sequences that the protocol generates. Add
the 'keyprotocol' option to allow the user to specify for which
terminal what protocol is to be used, instead of hard-coding this.
Add recognizing the kitty keyboard protocol status.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 23 Nov 2022 21:30:04 +0100 |
parents | 0ecb16d5f86f |
children | b1c66bff0a66 |
line wrap: on
line diff
--- a/src/terminal.c +++ b/src/terminal.c @@ -1587,6 +1587,13 @@ term_convert_key(term_T *term, int c, in if (modmask & (MOD_MASK_ALT | MOD_MASK_META)) mod |= VTERM_MOD_ALT; + // Ctrl-Shift-i may have the key "I" instead of "i", but for the kitty + // keyboard protocol should use "i". Applies to all ascii letters. + if (ASCII_ISUPPER(c) + && vterm_is_kitty_keyboard(curbuf->b_term->tl_vterm) + && mod == (VTERM_MOD_CTRL | VTERM_MOD_SHIFT)) + c = TOLOWER_ASC(c); + /* * Convert special keys to vterm keys: * - Write keys to vterm: vterm_keyboard_key() @@ -2182,6 +2189,19 @@ typedef enum { static reduce_key_state_T no_reduce_key_state = NRKS_NONE; +/* + * Return TRUE if the term is using modifyOtherKeys level 2 or the kitty + * keyboard protocol. + */ + static int +vterm_using_key_protocol(void) +{ + return curbuf->b_term != NULL + && curbuf->b_term->tl_vterm != NULL + && (vterm_is_modify_other_keys(curbuf->b_term->tl_vterm) + || vterm_is_kitty_keyboard(curbuf->b_term->tl_vterm)); +} + void check_no_reduce_keys(void) { @@ -2191,9 +2211,10 @@ check_no_reduce_keys(void) || curbuf->b_term->tl_vterm == NULL) return; - if (vterm_is_modify_other_keys(curbuf->b_term->tl_vterm)) - { - // "modify_other_keys" was enabled while waiting. + if (vterm_using_key_protocol()) + { + // "modify_other_keys" or kitty keyboard protocol was enabled while + // waiting. no_reduce_key_state = NRKS_SET; ++no_reduce_keys; } @@ -2216,8 +2237,7 @@ term_vgetc() ctrl_break_was_pressed = FALSE; #endif - if (curbuf->b_term->tl_vterm != NULL - && vterm_is_modify_other_keys(curbuf->b_term->tl_vterm)) + if (vterm_using_key_protocol()) { ++no_reduce_keys; no_reduce_key_state = NRKS_SET; @@ -2641,12 +2661,13 @@ raw_c_to_ctrl(int c) /* * When modify_other_keys is set then do the reverse of raw_c_to_ctrl(). + * Also when the Kitty keyboard protocol is used. * May set "mod_mask". */ static int ctrl_to_raw_c(int c) { - if (c < 0x20 && vterm_is_modify_other_keys(curbuf->b_term->tl_vterm)) + if (c < 0x20 && vterm_using_key_protocol()) { mod_mask |= MOD_MASK_CTRL; return c + '@';