0
0
mirror of https://github.com/vim/vim.git synced 2025-09-27 04:14:06 -04:00

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.
This commit is contained in:
Bram Moolenaar
2022-11-23 20:20:18 +00:00
parent 0b6d6a186e
commit 63a2e360cc
22 changed files with 381 additions and 43 deletions

View File

@@ -1587,6 +1587,13 @@ term_convert_key(term_T *term, int c, int modmask, char *buf)
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))
if (vterm_using_key_protocol())
{
// "modify_other_keys" was enabled while waiting.
// "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 + '@';