diff options
author | James McCoy <jamessan@jamessan.com> | 2020-07-04 00:26:47 -0400 |
---|---|---|
committer | James McCoy <jamessan@jamessan.com> | 2020-11-16 18:52:23 -0500 |
commit | e76f26d4e712a3a0ba30af90ecee70b85d1d400c (patch) | |
tree | 4d41eba97ed7bc9ce5a19c936ae4cd8030c1c262 | |
parent | e62beab71972bd30a56fe48766d8eb5e691c5cad (diff) | |
download | rneovim-e76f26d4e712a3a0ba30af90ecee70b85d1d400c.tar.gz rneovim-e76f26d4e712a3a0ba30af90ecee70b85d1d400c.tar.bz2 rneovim-e76f26d4e712a3a0ba30af90ecee70b85d1d400c.zip |
tui/input: Add S- modifier for chords with capital ASCII
termkey_strfkey() formats ctrl-l and ctrl-shift-l as <C-l> and <C-L>,
respectively. Nvim wants the latter to look like <C-S-L>, since <C-l>
and <C-L> are interpreted the same way.
This is only required when the Ctrl modifier is present.
-rw-r--r-- | src/nvim/tui/input.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index cc04920b32..94c326a5eb 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -9,6 +9,7 @@ #include "nvim/ascii.h" #include "nvim/charset.h" #include "nvim/main.h" +#include "nvim/macros.h" #include "nvim/aucmd.h" #include "nvim/ex_docmd.h" #include "nvim/option.h" @@ -200,8 +201,24 @@ static void forward_modified_utf8(TermInput *input, TermKeyKey *key) if (key->type == TERMKEY_TYPE_KEYSYM && key->code.sym == TERMKEY_SYM_SUSPEND) { len = (size_t)snprintf(buf, sizeof(buf), "<C-Z>"); + } else if (key->type != TERMKEY_TYPE_UNICODE) { + len = termkey_strfkey(input->tk, buf, sizeof(buf), key, TERMKEY_FORMAT_VIM); } else { + assert(key->modifiers); + // Termkey doesn't include the S- modifier for ASCII characters (e.g., + // ctrl-shift-l is <C-L> instead of <C-S-L>. Vim, on the other hand, + // treats <C-L> and <C-l> the same, requiring the S- modifier. len = termkey_strfkey(input->tk, buf, sizeof(buf), key, TERMKEY_FORMAT_VIM); + if ((key->modifiers & TERMKEY_KEYMOD_CTRL) + && !(key->modifiers & TERMKEY_KEYMOD_SHIFT) + && ASCII_ISUPPER(key->code.codepoint)) { + assert(len <= 62); + // Make remove for the S- + memmove(buf + 3, buf + 1, len - 1); + buf[1] = 'S'; + buf[2] = '-'; + len += 2; + } } tinput_enqueue(input, buf, len); |