0
0
mirror of https://github.com/vim/vim.git synced 2025-09-29 04:34:16 -04:00

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)
This commit is contained in:
Bram Moolenaar
2019-11-26 19:33:22 +01:00
parent cc4423ae13
commit fc4ea2a72d
11 changed files with 182 additions and 34 deletions

View File

@@ -1524,6 +1524,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.
@@ -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;
}