summaryrefslogtreecommitdiffstats
path: root/src/getchar.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-26 19:33:22 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-26 19:33:22 +0100
commitfc4ea2a72d36de1196a3ce17352e72f8fe90f4bb (patch)
treed5d681840040dc4e36b94bb94cef2cb972c052b0 /src/getchar.c
parentcc4423ae13d78367a3d0b5756783523d3b3a1d31 (diff)
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeysv8.1.2350
Problem: Other text for CTRL-V in Insert mode with modifyOtherKeys. Solution: Convert the Escape sequence back to key as if modifyOtherKeys is not set, and use CTRL-SHIFT-V to get the Escape sequence itself. (closes #5254)
Diffstat (limited to 'src/getchar.c')
-rw-r--r--src/getchar.c55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/getchar.c b/src/getchar.c
index b086126d9a..a3af879991 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1525,6 +1525,38 @@ updatescript(int c)
}
/*
+ * Convert "c" plus "mod_mask" to merge the effect of modifyOtherKeys into the
+ * character.
+ */
+ int
+merge_modifyOtherKeys(int c_arg)
+{
+ int c = c_arg;
+
+ if (mod_mask & MOD_MASK_CTRL)
+ {
+ if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
+ {
+ c &= 0x1f;
+ mod_mask &= ~MOD_MASK_CTRL;
+ }
+ else if (c == '6')
+ {
+ // CTRL-6 is equivalent to CTRL-^
+ c = 0x1e;
+ mod_mask &= ~MOD_MASK_CTRL;
+ }
+ }
+ if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT))
+ && c >= 0 && c <= 127)
+ {
+ c += 0x80;
+ mod_mask &= ~(MOD_MASK_META|MOD_MASK_ALT);
+ }
+ return c;
+}
+
+/*
* Get the next input character.
* Can return a special key or a multi-byte character.
* Can return NUL when called recursively, use safe_vgetc() if that's not
@@ -1765,30 +1797,9 @@ vgetc(void)
}
if (!no_reduce_keys)
- {
// A modifier was not used for a mapping, apply it to ASCII
// keys. Shift would already have been applied.
- if (mod_mask & MOD_MASK_CTRL)
- {
- if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
- {
- c &= 0x1f;
- mod_mask &= ~MOD_MASK_CTRL;
- }
- else if (c == '6')
- {
- // CTRL-6 is equivalent to CTRL-^
- c = 0x1e;
- mod_mask &= ~MOD_MASK_CTRL;
- }
- }
- if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT))
- && c >= 0 && c <= 127)
- {
- c += 0x80;
- mod_mask &= ~(MOD_MASK_META|MOD_MASK_ALT);
- }
- }
+ c = merge_modifyOtherKeys(c);
break;
}