changeset 20951:64c1b0796c46 v8.2.1027

patch 8.2.1027: GUI: multi-byte characters do not work in a terminal Commit: https://github.com/vim/vim/commit/820ffa567c5a4bc0d3517c79c91d63d8062c358e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 21 15:09:14 2020 +0200 patch 8.2.1027: GUI: multi-byte characters do not work in a terminal Problem: GUI: multi-byte characters do not work in a terminal. Solution: Do not assume a key is one byte. (closes https://github.com/vim/vim/issues/6304)
author Bram Moolenaar <Bram@vim.org>
date Sun, 21 Jun 2020 15:15:03 +0200
parents a8c5a81384da
children c297dfafbc7d
files src/gui_gtk_x11.c src/gui_x11.c src/version.c
diffstat 3 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -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)
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -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 '*'.
--- 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 */
 /**/
+    1027,
+/**/
     1026,
 /**/
     1025,