aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/keymap.c
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2016-02-20 17:09:15 -0500
committerJustin M. Keyes <justinkz@gmail.com>2016-02-22 02:41:40 -0500
commit99d4c8c29c4a9371c268cc20e4805709d86fb686 (patch)
tree6bedd829ee9f073f7940a2ed09ad6829318d71b5 /src/nvim/keymap.c
parent9403ce82bce1a2dcda4b01b10b2c01ee42bb4034 (diff)
downloadrneovim-99d4c8c29c4a9371c268cc20e4805709d86fb686.tar.gz
rneovim-99d4c8c29c4a9371c268cc20e4805709d86fb686.tar.bz2
rneovim-99d4c8c29c4a9371c268cc20e4805709d86fb686.zip
keymap: Support <D-...> (super/command key).
Adds support for: - api:vim_input("<D-a>") - ":nnoremap <C-D-S-...>" and permutations thereof UIs must capture the modifier and send it as "<D-...>" to vim_input(). Note: Before this commit, any arbitrary ":nnoremap <{foo}-{bar}>" mapping could already be invoked with feedkeys("\<{foo}-{bar}>"). This commit supports "D-" as a modifier that can be combined with "C-", "A-", "S-" in any order. For non-GUI (terminal) support, user must: :set <D-a>={CSI sequence} then send the {CSI sequence} from their terminal. But this does not work yet (regression #2204). Closes #2190
Diffstat (limited to 'src/nvim/keymap.c')
-rw-r--r--src/nvim/keymap.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/nvim/keymap.c b/src/nvim/keymap.c
index 65c808eb06..6c75d8bdf4 100644
--- a/src/nvim/keymap.c
+++ b/src/nvim/keymap.c
@@ -1,8 +1,3 @@
-/*
- * functions that use lookup tables for various things, generally to do with
- * special key codes.
- */
-
#include <assert.h>
#include <inttypes.h>
#include <limits.h>
@@ -39,7 +34,8 @@ static struct modmasktable {
{MOD_MASK_MULTI_CLICK, MOD_MASK_2CLICK, (char_u)'2'},
{MOD_MASK_MULTI_CLICK, MOD_MASK_3CLICK, (char_u)'3'},
{MOD_MASK_MULTI_CLICK, MOD_MASK_4CLICK, (char_u)'4'},
- /* 'A' must be the last one */
+ {MOD_MASK_CMD, MOD_MASK_CMD, (char_u)'D'},
+ // 'A' must be the last one
{MOD_MASK_ALT, MOD_MASK_ALT, (char_u)'A'},
{0, 0, NUL}
};
@@ -658,9 +654,11 @@ static int extract_modifiers(int key, int *modp)
{
int modifiers = *modp;
- if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) {
- key = TOUPPER_ASC(key);
- modifiers &= ~MOD_MASK_SHIFT;
+ if (!(modifiers & MOD_MASK_CMD)) { // Command-key is special
+ if ((modifiers & MOD_MASK_SHIFT) && ASCII_ISALPHA(key)) {
+ key = TOUPPER_ASC(key);
+ modifiers &= ~MOD_MASK_SHIFT;
+ }
}
if ((modifiers & MOD_MASK_CTRL)
&& ((key >= '?' && key <= '_') || ASCII_ISALPHA(key))) {