Patch 8.2.1019

4 views
Skip to first unread message

Bram Moolenaar

unread,
Jun 20, 2020, 8:44:02 AM6/20/20
to vim...@googlegroups.com

Patch 8.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.
Files: src/gui_gtk_x11.c, src/misc2.c, src/proto/misc2.pro, src/term.c


*** ../vim-8.2.1018/src/gui_gtk_x11.c 2020-05-31 13:53:01.548186282 +0200
--- src/gui_gtk_x11.c 2020-06-20 14:30:03.179918323 +0200
***************
*** 1211,1225 ****
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];

key = simplify_key(key, &modifiers);
if (key == CSI)
key = K_CSI;
--- 1211,1226 ----
if (len == 0) // Unrecognized key
return TRUE;

// 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,1240 ****
--- 1236,1245 ----
// <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;
}
*** ../vim-8.2.1018/src/misc2.c 2020-06-19 21:46:48.534308768 +0200
--- src/misc2.c 2020-06-20 14:29:51.783949940 +0200
***************
*** 2910,2915 ****
--- 2910,2934 ----
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.
*** ../vim-8.2.1018/src/proto/misc2.pro 2020-06-07 20:49:02.073891895 +0200
--- src/proto/misc2.pro 2020-06-20 14:29:48.231959793 +0200
***************
*** 71,76 ****
--- 71,77 ----
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);
*** ../vim-8.2.1018/src/term.c 2020-06-19 21:46:48.534308768 +0200
--- src/term.c 2020-06-20 14:29:57.415934322 +0200
***************
*** 4769,4785 ****

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;

// When used with Ctrl we always make a letter upper case,
// so that mapping <C-H> and <C-h> are the same. Typing
--- 4769,4776 ----

modifiers = decode_modifiers(arg[1]);

! // 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
*** ../vim-8.2.1018/src/version.c 2020-06-20 13:28:59.789336842 +0200
--- src/version.c 2020-06-20 14:25:28.432673156 +0200
***************
*** 756,757 ****
--- 756,759 ----
{ /* Add new patch number below this line */
+ /**/
+ 1019,
/**/

--
In Africa some of the native tribes have a custom of beating the ground
with clubs and uttering spine chilling cries. Anthropologists call
this a form of primitive self-expression. In America we call it golf.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages