diff options
author | Bram Moolenaar <Bram@vim.org> | 2020-06-20 14:43:23 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2020-06-20 14:43:23 +0200 |
commit | ef6746f637adbdb6860b4fa0266c43c49fa498bc (patch) | |
tree | bc6c972c44330f8abab831c728f535326d35aaa8 | |
parent | 280b0dc815a31b99dafc384baa415072e5f2bec1 (diff) | |
download | vim-git-8.2.1019.tar.gz |
patch 8.2.1019: mapping <M-S-a> does not work in the GUIv8.2.1019
Problem: Mapping <M-S-a> does not work in the GUI.
Solution: Move the logic to remove the shift modifier to
may_remove_shift_modifier() and also use it in the GUI.
-rw-r--r-- | src/gui_gtk_x11.c | 11 | ||||
-rw-r--r-- | src/misc2.c | 19 | ||||
-rw-r--r-- | src/proto/misc2.pro | 1 | ||||
-rw-r--r-- | src/term.c | 13 | ||||
-rw-r--r-- | src/version.c | 2 |
5 files changed, 32 insertions, 14 deletions
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index a5af3fa21..b2770ca47 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -1211,15 +1211,16 @@ key_press_event(GtkWidget *widget UNUSED, if (len == 0) // Unrecognized key return TRUE; - // Handle modifiers. - modifiers = modifiers_gdk2vim(state); - // For some keys a shift modifier is translated into another key code. if (len == -3) key = TO_SPECIAL(string[1], string[2]); else key = string[0]; + // Handle modifiers. + modifiers = modifiers_gdk2vim(state); + + // Recognize special keys. key = simplify_key(key, &modifiers); if (key == CSI) key = K_CSI; @@ -1235,6 +1236,10 @@ key_press_event(GtkWidget *widget UNUSED, // <C-H> and <C-h> mean the same thing, always use "H" if ((modifiers & MOD_MASK_CTRL) && ASCII_ISALPHA(key)) key = TOUPPER_ASC(key); + + // May remove the shift modifier if it's included in the key. + modifiers = may_remove_shift_modifier(modifiers, key); + string[0] = key; len = 1; } diff --git a/src/misc2.c b/src/misc2.c index 649cb65c9..7ef6cdf44 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -2910,6 +2910,25 @@ find_special_key( return 0; } + +/* + * 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>. + */ + int +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 <= '~'))) + return modifiers & ~MOD_MASK_SHIFT; + return modifiers; +} + /* * Try to include modifiers in the key. * Changes "Shift-a" to 'A', "Alt-A" to 0xc0, etc. diff --git a/src/proto/misc2.pro b/src/proto/misc2.pro index 347745252..e1e20aaab 100644 --- a/src/proto/misc2.pro +++ b/src/proto/misc2.pro @@ -71,6 +71,7 @@ char_u *get_special_key_name(int c, int modifiers); int trans_special(char_u **srcp, char_u *dst, int flags, int *did_simplify); int special_to_buf(int key, int modifiers, int keycode, char_u *dst); int find_special_key(char_u **srcp, int *modp, int flags, int *did_simplify); +int may_remove_shift_modifier(int modifiers, int key); int extract_modifiers(int key, int *modp, int simplify, int *did_simplify); int find_special_key_in_table(int c); int get_special_key_code(char_u *name); diff --git a/src/term.c b/src/term.c index 1556c2eec..3bda87ccc 100644 --- a/src/term.c +++ b/src/term.c @@ -4769,17 +4769,8 @@ handle_key_with_modifier( modifiers = decode_modifiers(arg[1]); - // 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>. - 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 <= '~'))) - modifiers &= ~MOD_MASK_SHIFT; + // May remove the shift modifier if it's already included in the key. + modifiers = may_remove_shift_modifier(modifiers, key); // When used with Ctrl we always make a letter upper case, // so that mapping <C-H> and <C-h> are the same. Typing diff --git a/src/version.c b/src/version.c index fdb7c9f9e..5d7e45135 100644 --- a/src/version.c +++ b/src/version.c @@ -755,6 +755,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1019, +/**/ 1018, /**/ 1017, |