summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-09-27 13:16:46 +0200
committerBram Moolenaar <Bram@vim.org>2020-09-27 13:16:46 +0200
commitdaff0fb73851ef368ede180dbb3b772e55304ba7 (patch)
treef670323f2ceef7078bb26398eb8b72871f1e6046 /src
parentbade44e5cad1b08c85d4a8ba08d94a30458dddfb (diff)
patch 8.2.1752: GTK GUI: cannot map alt-? with <A-?>v8.2.1752
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.
Diffstat (limited to 'src')
-rw-r--r--src/gui_w32.c3
-rw-r--r--src/gui_x11.c3
-rw-r--r--src/misc2.c6
-rw-r--r--src/testdir/test_termcodes.vim14
-rw-r--r--src/version.c2
5 files changed, 22 insertions, 6 deletions
diff --git a/src/gui_w32.c b/src/gui_w32.c
index 19db1a33ad..5bc5a3903d 100644
--- a/src/gui_w32.c
+++ b/src/gui_w32.c
@@ -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);
diff --git a/src/gui_x11.c b/src/gui_x11.c
index 1402407c2f..f1d9bf8e58 100644
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -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)
diff --git a/src/misc2.c b/src/misc2.c
index 0370bdf0d3..3781dd85d2 100644
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -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;
diff --git a/src/testdir/test_termcodes.vim b/src/testdir/test_termcodes.vim
index f3a7af5968..91ccda8ca9 100644
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -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)
diff --git a/src/version.c b/src/version.c
index 90ec322f4d..149a3ff212 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1752,
+/**/
1751,
/**/
1750,