Mercurial > vim
diff src/getchar.c @ 18717:14d2a210fab1 v8.1.2350
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
Commit: https://github.com/vim/vim/commit/fc4ea2a72d36de1196a3ce17352e72f8fe90f4bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Nov 26 19:33:22 2019 +0100
patch 8.1.2350: other text for CTRL-V in Insert mode with modifyOtherKeys
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)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 26 Nov 2019 19:45:04 +0100 |
parents | 8cc12c8d7842 |
children | 49b78d6465e5 |
line wrap: on
line diff
--- 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; }