summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2020-05-30 19:52:46 +0200
committerBram Moolenaar <Bram@vim.org>2020-05-30 19:52:46 +0200
commitf4ae6b245a54f11dd967d06b80f30e5abf55fb82 (patch)
tree2168d44f4056abd29debc3939158f31add0bf3e0
parent95da136142628e06425f9d9eb2d1ca56a9e48feb (diff)
downloadvim-git-f4ae6b245a54f11dd967d06b80f30e5abf55fb82.tar.gz
patch 8.2.0851: can't distinguish <M-a> from accented "a" in the GUIv8.2.0851
Problem: Can't distinguish <M-a> from accented "a" in the GUI. Solution: Use another way to make mapping <C-bslash> work. (closes #6163)
-rw-r--r--src/getchar.c20
-rw-r--r--src/gui.c4
-rw-r--r--src/gui_gtk_x11.c44
-rw-r--r--src/version.c2
4 files changed, 28 insertions, 42 deletions
diff --git a/src/getchar.c b/src/getchar.c
index 312f3c1db..ace56863e 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -1593,16 +1593,26 @@ merge_modifyOtherKeys(int c_arg)
if (mod_mask & MOD_MASK_CTRL)
{
if ((c >= '`' && c <= 0x7f) || (c >= '@' && c <= '_'))
- {
c &= 0x1f;
- mod_mask &= ~MOD_MASK_CTRL;
- }
else if (c == '6')
- {
// CTRL-6 is equivalent to CTRL-^
c = 0x1e;
+#ifdef FEAT_GUI_GTK
+ // These mappings look arbitrary at the first glance, but in fact
+ // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my
+ // machine. The only difference is BS vs. DEL for CTRL-8 (makes
+ // more sense and is consistent with usual terminal behaviour).
+ else if (c == '2')
+ c = NUL;
+ else if (c >= '3' && c <= '7')
+ c = c ^ 0x28;
+ else if (c == '8')
+ c = BS;
+ else if (c == '?')
+ c = DEL;
+#endif
+ if (c != c_arg)
mod_mask &= ~MOD_MASK_CTRL;
- }
}
if ((mod_mask & (MOD_MASK_META | MOD_MASK_ALT))
&& c >= 0 && c <= 127)
diff --git a/src/gui.c b/src/gui.c
index a7216fcf6..3df992148 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -803,8 +803,8 @@ gui_init(void)
if (!p_beval)
gui_mch_disable_beval_area(balloonEval);
#endif
- // In case the terminal was used before ":gui".
- seenModifyOtherKeys = FALSE;
+ // In the GUI modifiers are prepended to keys.
+ seenModifyOtherKeys = TRUE;
#if defined(FEAT_XIM) && defined(FEAT_GUI_GTK)
if (!im_xim_isvalid_imactivate())
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 8e272970d..96e70a88e 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -1018,12 +1018,11 @@ focus_out_event(GtkWidget *widget UNUSED,
* The output is written to string, which must have room for at least 6 bytes
* plus the NUL terminator. Returns the length in bytes.
*
- * This function is used in the GTK+ 2 GUI only. The GTK+ 1 code makes use
- * of GdkEventKey::string instead. But event->string is evil; see here why:
+ * event->string is evil; see here why:
* http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html#GdkEventKey
*/
static int
-keyval_to_string(unsigned int keyval, unsigned int *state, char_u *string)
+keyval_to_string(unsigned int keyval, char_u *string)
{
int len;
guint32 uc;
@@ -1031,37 +1030,9 @@ keyval_to_string(unsigned int keyval, unsigned int *state, char_u *string)
uc = gdk_keyval_to_unicode(keyval);
if (uc != 0)
{
- // Check for CTRL-char
- if ((*state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80)
- {
- // These mappings look arbitrary at the first glance, but in fact
- // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my
- // machine. The only difference is BS vs. DEL for CTRL-8 (makes
- // more sense and is consistent with usual terminal behaviour).
- if (uc >= '@')
- string[0] = uc & 0x1F;
- else if (uc == '2')
- string[0] = NUL;
- else if (uc >= '3' && uc <= '7')
- string[0] = uc ^ 0x28;
- else if (uc == '8')
- string[0] = BS;
- else if (uc == '?')
- string[0] = DEL;
- else
- string[0] = uc;
- len = 1;
-
- if (string[0] != uc)
- // The modifier was used, remove it.
- *state = *state & ~GDK_CONTROL_MASK;
- }
- else
- {
- // Translate a normal key to UTF-8. This doesn't work for dead
- // keys of course, you _have_ to use an input method for that.
- len = utf_char2bytes((int)uc, string);
- }
+ // Translate a normal key to UTF-8. This doesn't work for dead
+ // keys of course, you _have_ to use an input method for that.
+ len = utf_char2bytes((int)uc, string);
}
else
{
@@ -1173,7 +1144,7 @@ key_press_event(GtkWidget *widget UNUSED,
else
#endif
{
- len = keyval_to_string(key_sym, &state, string2);
+ len = keyval_to_string(key_sym, string2);
// Careful: convert_input() doesn't handle the NUL character.
// No need to convert pure ASCII anyway, thus the len > 1 check.
@@ -1261,6 +1232,9 @@ key_press_event(GtkWidget *widget UNUSED,
}
else
{
+ // <C-H> and <C-h> mean the same thing, always use "H"
+ if ((modifiers & MOD_MASK_CTRL) && ASCII_ISALPHA(key))
+ key = TOUPPER_ASC(key);
string[0] = key;
len = 1;
}
diff --git a/src/version.c b/src/version.c
index 6fb570d1f..da3169959 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 851,
+/**/
850,
/**/
849,