From e76f26d4e712a3a0ba30af90ecee70b85d1d400c Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sat, 4 Jul 2020 00:26:47 -0400 Subject: tui/input: Add S- modifier for chords with capital ASCII termkey_strfkey() formats ctrl-l and ctrl-shift-l as and , respectively. Nvim wants the latter to look like , since and are interpreted the same way. This is only required when the Ctrl modifier is present. --- src/nvim/tui/input.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') 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), ""); + } 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 instead of . Vim, on the other hand, + // treats and 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); -- cgit