]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 8.2.1027: GUI: multi-byte characters do not work in a terminal v8.2.1027
authorBram Moolenaar <Bram@vim.org>
Sun, 21 Jun 2020 13:09:14 +0000 (15:09 +0200)
committerBram Moolenaar <Bram@vim.org>
Sun, 21 Jun 2020 13:09:14 +0000 (15:09 +0200)
Problem:    GUI: multi-byte characters do not work in a terminal.
Solution:   Do not assume a key is one byte. (closes #6304)

src/gui_gtk_x11.c
src/gui_x11.c
src/version.c

index b2770ca47fc0ff56329ede00bfb58be6b3206327..40de6663135f89db05655114ecef3ba2fe80b29a 100644 (file)
@@ -1215,7 +1215,10 @@ key_press_event(GtkWidget *widget UNUSED,
     if (len == -3)
        key = TO_SPECIAL(string[1], string[2]);
     else
-       key = string[0];
+    {
+       string[len] = NUL;
+       key = mb_ptr2char(string);
+    }
 
     // Handle modifiers.
     modifiers = modifiers_gdk2vim(state);
@@ -1240,8 +1243,7 @@ key_press_event(GtkWidget *widget UNUSED,
        // May remove the shift modifier if it's included in the key.
        modifiers = may_remove_shift_modifier(modifiers, key);
 
-       string[0] = key;
-       len = 1;
+       len = mb_char2bytes(key, string);
     }
 
     if (modifiers != 0)
index a64bc3bd9c7038d6ea3b683717769bc29b873ab7..26d02e77387a63e56aa781fd753ce095ddf6b528 100644 (file)
@@ -938,7 +938,10 @@ gui_x11_key_hit_cb(
     if (len == -3)
        key = TO_SPECIAL(string[1], string[2]);
     else
-       key = string[0];
+    {
+       string[len] = NUL;
+       key = mb_ptr2char(string);
+    }
     key = simplify_key(key, &modifiers);
     if (key == CSI)
        key = K_CSI;
@@ -951,8 +954,7 @@ gui_x11_key_hit_cb(
     }
     else
     {
-       string[0] = key;
-       len = 1;
+       len = mb_char2bytes(key, string);
 
        // Remove the SHIFT modifier for keys where it's already included,
        // e.g., '(', '!' and '*'.
index dad247833c7a577c8c8d0e3dec081168572d2849..b78659134a14adf6043e6a8429e5662ce0f16267 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1027,
 /**/
     1026,
 /**/