mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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.
This commit is contained in:
parent
e62beab719
commit
e76f26d4e7
@ -9,6 +9,7 @@
|
|||||||
#include "nvim/ascii.h"
|
#include "nvim/ascii.h"
|
||||||
#include "nvim/charset.h"
|
#include "nvim/charset.h"
|
||||||
#include "nvim/main.h"
|
#include "nvim/main.h"
|
||||||
|
#include "nvim/macros.h"
|
||||||
#include "nvim/aucmd.h"
|
#include "nvim/aucmd.h"
|
||||||
#include "nvim/ex_docmd.h"
|
#include "nvim/ex_docmd.h"
|
||||||
#include "nvim/option.h"
|
#include "nvim/option.h"
|
||||||
@ -200,8 +201,24 @@ static void forward_modified_utf8(TermInput *input, TermKeyKey *key)
|
|||||||
if (key->type == TERMKEY_TYPE_KEYSYM
|
if (key->type == TERMKEY_TYPE_KEYSYM
|
||||||
&& key->code.sym == TERMKEY_SYM_SUSPEND) {
|
&& key->code.sym == TERMKEY_SYM_SUSPEND) {
|
||||||
len = (size_t)snprintf(buf, sizeof(buf), "<C-Z>");
|
len = (size_t)snprintf(buf, sizeof(buf), "<C-Z>");
|
||||||
} else {
|
} else if (key->type != TERMKEY_TYPE_UNICODE) {
|
||||||
len = termkey_strfkey(input->tk, buf, sizeof(buf), key, TERMKEY_FORMAT_VIM);
|
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);
|
tinput_enqueue(input, buf, len);
|
||||||
|
Loading…
Reference in New Issue
Block a user