diff src/misc2.c @ 22522:6c7e4db139a3 v8.2.1809

patch 8.2.1809: mapping some keys with Ctrl does not work properly Commit: https://github.com/vim/vim/commit/4e2114e988f5d8635f2ad748be3cafcc44289138 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Oct 7 16:12:37 2020 +0200 patch 8.2.1809: mapping some keys with Ctrl does not work properly Problem: Mapping some keys with Ctrl does not work properly. Solution: For terminal, GTK and Motif handle "@", "^" and "_" codes.
author Bram Moolenaar <Bram@vim.org>
date Wed, 07 Oct 2020 16:15:04 +0200
parents c19acd92ee83
children 6325ef9143bc
line wrap: on
line diff
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -2947,6 +2947,32 @@ find_special_key(
 
 
 /*
+ * Some keys are used with Ctrl without Shift and are still expected to be
+ * mapped as if Shift was pressed:
+ * CTRL-2 is CTRL-@
+ * CTRL-6 is CTRL-^
+ * CTRL-- is CTRL-_
+ * Also, <C-H> and <C-h> mean the same thing, always use "H".
+ * Returns the possibly adjusted key.
+ */
+    int
+may_adjust_key_for_ctrl(int modifiers, int key)
+{
+    if (modifiers & MOD_MASK_CTRL)
+    {
+	if (ASCII_ISALPHA(key))
+	    return TOUPPER_ASC(key);
+	if (key == '2')
+	    return '@';
+	if (key == '6')
+	    return '^';
+	if (key == '-')
+	    return '_';
+    }
+    return key;
+}
+
+/*
  * Some keys already have Shift included, pass them as normal keys.
  * Not when Ctrl is also used, because <C-H> and <C-S-H> are different.
  * Also for <A-S-a> and <M-S-a>.