Skip to content

Commit ea83c19

Browse files
committed
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 #11913)
1 parent 2a00317 commit ea83c19

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/getchar.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1623,13 +1623,14 @@ updatescript(int c)
16231623

16241624
/*
16251625
* Convert "c" plus "modifiers" to merge the effect of modifyOtherKeys into the
1626-
* character.
1626+
* character. Also for when the Kitty key protocol is used.
16271627
*/
16281628
int
16291629
merge_modifyOtherKeys(int c_arg, int *modifiers)
16301630
{
16311631
int c = c_arg;
16321632

1633+
// CTRL only uses the lower 5 bits of the character.
16331634
if (*modifiers & MOD_MASK_CTRL)
16341635
{
16351636
if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
@@ -1658,12 +1659,23 @@ merge_modifyOtherKeys(int c_arg, int *modifiers)
16581659
if (c != c_arg)
16591660
*modifiers &= ~MOD_MASK_CTRL;
16601661
}
1662+
1663+
// Alt/Meta sets the 8th bit of the character.
16611664
if ((*modifiers & (MOD_MASK_META | MOD_MASK_ALT))
16621665
&& c >= 0 && c <= 127)
16631666
{
1667+
// Some terminals (esp. Kitty) do not include Shift in the character.
1668+
// Apply it here to get consistency across terminals. Only do ASCII
1669+
// letters, for other characters it depends on the keyboard layout.
1670+
if ((*modifiers & MOD_MASK_SHIFT) && c >= 'a' && c <= 'z')
1671+
{
1672+
c += 'a' - 'A';
1673+
*modifiers &= ~MOD_MASK_SHIFT;
1674+
}
16641675
c += 0x80;
16651676
*modifiers &= ~(MOD_MASK_META | MOD_MASK_ALT);
16661677
}
1678+
16671679
return c;
16681680
}
16691681

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,8 @@ static char *(features[]) =
695695

696696
static int included_patches[] =
697697
{ /* Add new patch number below this line */
698+
/**/
699+
1414,
698700
/**/
699701
1413,
700702
/**/

0 commit comments

Comments
 (0)