]> granicus.if.org Git - vim/commitdiff
patch 8.2.1752: GTK GUI: cannot map alt-? with <A-?> v8.2.1752
authorBram Moolenaar <Bram@vim.org>
Sun, 27 Sep 2020 11:16:46 +0000 (13:16 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 27 Sep 2020 11:16:46 +0000 (13:16 +0200)
Problem:    GTK GUI: cannot map alt-? with <A-?>. (Ingo Karkat)
Solution:   Adjust the characters for which the shift modifier is removed.
            (closes #7016)  Make Motif and Win32 use the same function as GTK.

src/gui_w32.c
src/gui_x11.c
src/misc2.c
src/testdir/test_termcodes.vim
src/version.c

index 19db1a33ad3e73993b7177b56837091dab4115dd..5bc5a3903d8e3bfbe5488196a04862b5144a5f5f 100644 (file)
@@ -842,8 +842,7 @@ _OnSysChar(
     ch = simplify_key(ch, &modifiers);
     // remove the SHIFT modifier for keys where it's already included, e.g.,
     // '(' and '*'
-    if (ch < 0x100 && !isalpha(ch) && isprint(ch))
-       modifiers &= ~MOD_MASK_SHIFT;
+    modifiers = may_remove_shift_modifier(modifiers, ch);
 
     // Unify modifiers somewhat.  No longer use ALT to set the 8th bit.
     ch = extract_modifiers(ch, &modifiers, FALSE, NULL);
index 1402407c2f286f3f0e292ced12e0c2719198ff52..f1d9bf8e5877fa4d07ee2a508b3200f9f388d96d 100644 (file)
@@ -958,8 +958,7 @@ gui_x11_key_hit_cb(
 
        // Remove the SHIFT modifier for keys where it's already included,
        // e.g., '(', '!' and '*'.
-       if (!ASCII_ISALPHA(key) && key > 0x20 && key < 0x7f)
-           modifiers &= ~MOD_MASK_SHIFT;
+       modifiers = may_remove_shift_modifier(modifiers, key);
     }
 
     if (modifiers != 0)
index 0370bdf0d3a594f3ca53ff46d9ccfd7442a52e2d..3781dd85d291192b71da383cca979f5063c0c2aa 100644 (file)
@@ -2950,6 +2950,7 @@ find_special_key(
  * Some keys already have Shift included, pass them as normal keys.
  * Not when Ctrl is also used, because <C-H> and <C-S-H> are different.
  * Also for <A-S-a> and <M-S-a>.
+ * This includes all printable ASCII characters except numbers and a-z.
  */
     int
 may_remove_shift_modifier(int modifiers, int key)
@@ -2957,8 +2958,9 @@ may_remove_shift_modifier(int modifiers, int key)
     if ((modifiers == MOD_MASK_SHIFT
                || modifiers == (MOD_MASK_SHIFT | MOD_MASK_ALT)
                || modifiers == (MOD_MASK_SHIFT | MOD_MASK_META))
-           && ((key >= '@' && key <= 'Z')
-               || key == '^' || key == '_'
+           && ((key >= '!' && key <= '/')
+               || (key >= ':' && key <= 'Z')
+               || (key >= '[' && key <= '`')
                || (key >= '{' && key <= '~')))
        return modifiers & ~MOD_MASK_SHIFT;
     return modifiers;
index f3a7af59684e8001b5665c518051401a21520f98..91ccda8ca9f1953fe50976edecdd6bd4b34e20c4 100644 (file)
@@ -2123,6 +2123,20 @@ func Test_mapping_works_with_shift_alt()
   call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'S-A', 4)
 endfunc
 
+func Test_mapping_works_with_alt_and_shift()
+  new
+  set timeoutlen=10
+
+  " mapping <A-?> works even though the code is A-S-?
+  for c in ['!', '$', '+', ':', '?', '^', '~']
+    call RunTest_mapping_mods('<A-' .. c .. '>', c, function('GetEscCodeCSI27'), 4)
+    call RunTest_mapping_mods('<A-' .. c .. '>', c, function('GetEscCodeCSIu'), 4)
+  endfor
+
+  bwipe!
+  set timeoutlen&
+endfunc
+
 func Test_mapping_works_with_ctrl_alt()
   call RunTest_mapping_works_with_mods(function('GetEscCodeCSI27'), 'C-A', 7)
   call RunTest_mapping_works_with_mods(function('GetEscCodeCSIu'), 'C-A', 7)
index 90ec322f4d0271c12e77855d5e979645baec43af..149a3ff212bc3988f26edecd4ca2980be79d3ae1 100644 (file)
@@ -750,6 +750,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1752,
 /**/
     1751,
 /**/