aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2020-11-20 09:15:39 -0500
committerGitHub <noreply@github.com>2020-11-20 09:15:39 -0500
commit978857e0c25384489c08309ec8128d3a1c8b5e3e (patch)
treecfc3a74eb076710784cd04e2e4e2fa96bd74b571 /src
parent480b04122e93826bdfc74fbeacab2d94b089420f (diff)
parenta88bc4d95ebcddae7364c932b45b71ffc109b190 (diff)
downloadrneovim-978857e0c25384489c08309ec8128d3a1c8b5e3e.tar.gz
rneovim-978857e0c25384489c08309ec8128d3a1c8b5e3e.tar.bz2
rneovim-978857e0c25384489c08309ec8128d3a1c8b5e3e.zip
Merge pull request #12592 from jamessan/fix-mod-keys
Diffstat (limited to 'src')
-rw-r--r--src/nvim/keymap.c4
-rw-r--r--src/nvim/tui/input.c20
2 files changed, 20 insertions, 4 deletions
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 2b6f022d9d..517274a1d3 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -156,6 +156,7 @@ static const struct key_name_entry {
{ K_BS, "BS" },
{ K_BS, "BackSpace" }, // Alternative name
{ ESC, "Esc" },
+ { ESC, "Escape" }, // Alternative name
{ CSI, "CSI" },
{ K_CSI, "xCSI" },
{ '|', "Bar" },
@@ -711,7 +712,8 @@ static int extract_modifiers(int key, int *modp)
{
int modifiers = *modp;
- if (!(modifiers & MOD_MASK_CMD)) { // Command-key is special
+ // Command-key and ctrl are special
+ if (!(modifiers & MOD_MASK_CMD) && !(modifiers & MOD_MASK_CTRL)) {
if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) {
key = TOUPPER_ASC(key);
modifiers &= ~MOD_MASK_SHIFT;
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c
index bbee7e4712..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"
@@ -198,13 +199,26 @@ static void forward_modified_utf8(TermInput *input, TermKeyKey *key)
char buf[64];
if (key->type == TERMKEY_TYPE_KEYSYM
- && key->code.sym == TERMKEY_SYM_ESCAPE) {
- len = (size_t)snprintf(buf, sizeof(buf), "<Esc>");
- } else 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);