Mercurial > vim
changeset 32166:cf48f4b9dc0a v9.0.1414
patch 9.0.1414: <M-S-x> in Kitty does not use the Shift modifier
Commit: https://github.com/vim/vim/commit/ea83c194625e51c28a2796eba9ba87b0b9ab23e0
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Mar 18 17:22:46 2023 +0000
patch 9.0.1414: <M-S-x> in Kitty does not use the Shift modifier
Problem: <M-S-x> in Kitty does not use the Shift modifier.
Solution: Apply the Shift modifier to ASCII letters. (closes https://github.com/vim/vim/issues/11913)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Mar 2023 18:30:04 +0100 |
parents | 4e6cc56ca41c |
children | 3954e4aec820 |
files | src/getchar.c src/version.c |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/getchar.c +++ b/src/getchar.c @@ -1623,13 +1623,14 @@ updatescript(int c) /* * Convert "c" plus "modifiers" to merge the effect of modifyOtherKeys into the - * character. + * character. Also for when the Kitty key protocol is used. */ int merge_modifyOtherKeys(int c_arg, int *modifiers) { int c = c_arg; + // CTRL only uses the lower 5 bits of the character. if (*modifiers & MOD_MASK_CTRL) { if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_')) @@ -1658,12 +1659,23 @@ merge_modifyOtherKeys(int c_arg, int *mo if (c != c_arg) *modifiers &= ~MOD_MASK_CTRL; } + + // Alt/Meta sets the 8th bit of the character. if ((*modifiers & (MOD_MASK_META | MOD_MASK_ALT)) && c >= 0 && c <= 127) { + // Some terminals (esp. Kitty) do not include Shift in the character. + // Apply it here to get consistency across terminals. Only do ASCII + // letters, for other characters it depends on the keyboard layout. + if ((*modifiers & MOD_MASK_SHIFT) && c >= 'a' && c <= 'z') + { + c += 'a' - 'A'; + *modifiers &= ~MOD_MASK_SHIFT; + } c += 0x80; *modifiers &= ~(MOD_MASK_META | MOD_MASK_ALT); } + return c; }