]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1414: <M-S-x> in Kitty does not use the Shift modifier v9.0.1414
authorBram Moolenaar <Bram@vim.org>
Sat, 18 Mar 2023 17:22:46 +0000 (17:22 +0000)
committerBram Moolenaar <Bram@vim.org>
Sat, 18 Mar 2023 17:22:46 +0000 (17:22 +0000)
Problem:    <M-S-x> in Kitty does not use the Shift modifier.
Solution:   Apply the Shift modifier to ASCII letters. (closes #11913)

src/getchar.c
src/version.c

index dac57eb26c614d8ca6d8542aa6fc8c46a11477a4..125f0b0aadf37e59f2ac5d52d205546944d61977 100644 (file)
@@ -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 *modifiers)
        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;
 }
 
index 98369f6837e264c90b47f6ce0b88960d568bd6dc..277e52258b75e0269e555da43dcdbffd63bb6dd4 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1414,
 /**/
     1413,
 /**/