Mercurial > vim
comparison src/gui_gtk_x11.c @ 20431:682513df5af1 v8.2.0770
patch 8.2.0770: cannot map CTRL-B when using the GUI
Commit: https://github.com/vim/vim/commit/aa5fc4ec51b00e91f174ac83c8ff68becf5f42bb
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat May 16 18:57:53 2020 +0200
patch 8.2.0770: cannot map CTRL-B when using the GUI
Problem: Cannot map CTRL-B when using the GUI.
Solution: Reset the CTRL modifier when used. (closes https://github.com/vim/vim/issues/6092)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 16 May 2020 19:00:07 +0200 |
parents | 8590a462ad46 |
children | 3609e842f822 |
comparison
equal
deleted
inserted
replaced
20430:df50f7b7830d | 20431:682513df5af1 |
---|---|
1021 * This function is used in the GTK+ 2 GUI only. The GTK+ 1 code makes use | 1021 * This function is used in the GTK+ 2 GUI only. The GTK+ 1 code makes use |
1022 * of GdkEventKey::string instead. But event->string is evil; see here why: | 1022 * of GdkEventKey::string instead. But event->string is evil; see here why: |
1023 * http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html#GdkEventKey | 1023 * http://developer.gnome.org/doc/API/2.0/gdk/gdk-Event-Structures.html#GdkEventKey |
1024 */ | 1024 */ |
1025 static int | 1025 static int |
1026 keyval_to_string(unsigned int keyval, unsigned int state, char_u *string) | 1026 keyval_to_string(unsigned int keyval, unsigned int *state, char_u *string) |
1027 { | 1027 { |
1028 int len; | 1028 int len; |
1029 guint32 uc; | 1029 guint32 uc; |
1030 | 1030 |
1031 uc = gdk_keyval_to_unicode(keyval); | 1031 uc = gdk_keyval_to_unicode(keyval); |
1032 if (uc != 0) | 1032 if (uc != 0) |
1033 { | 1033 { |
1034 // Check for CTRL-foo | 1034 // Check for CTRL-char |
1035 if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80) | 1035 if ((*state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80) |
1036 { | 1036 { |
1037 // These mappings look arbitrary at the first glance, but in fact | 1037 // These mappings look arbitrary at the first glance, but in fact |
1038 // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my | 1038 // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my |
1039 // machine. The only difference is BS vs. DEL for CTRL-8 (makes | 1039 // machine. The only difference is BS vs. DEL for CTRL-8 (makes |
1040 // more sense and is consistent with usual terminal behaviour). | 1040 // more sense and is consistent with usual terminal behaviour). |
1049 else if (uc == '?') | 1049 else if (uc == '?') |
1050 string[0] = DEL; | 1050 string[0] = DEL; |
1051 else | 1051 else |
1052 string[0] = uc; | 1052 string[0] = uc; |
1053 len = 1; | 1053 len = 1; |
1054 | |
1055 if (string[0] != uc) | |
1056 // The modifier was used, remove it. | |
1057 *state = *state & ~GDK_CONTROL_MASK; | |
1054 } | 1058 } |
1055 else | 1059 else |
1056 { | 1060 { |
1057 // Translate a normal key to UTF-8. This doesn't work for dead | 1061 // Translate a normal key to UTF-8. This doesn't work for dead |
1058 // keys of course, you _have_ to use an input method for that. | 1062 // keys of course, you _have_ to use an input method for that. |
1167 if (key_sym == SunXK_F36 || key_sym == SunXK_F37) | 1171 if (key_sym == SunXK_F36 || key_sym == SunXK_F37) |
1168 len = 0; | 1172 len = 0; |
1169 else | 1173 else |
1170 #endif | 1174 #endif |
1171 { | 1175 { |
1172 len = keyval_to_string(key_sym, state, string2); | 1176 len = keyval_to_string(key_sym, &state, string2); |
1173 | 1177 |
1174 // Careful: convert_input() doesn't handle the NUL character. | 1178 // Careful: convert_input() doesn't handle the NUL character. |
1175 // No need to convert pure ASCII anyway, thus the len > 1 check. | 1179 // No need to convert pure ASCII anyway, thus the len > 1 check. |
1176 if (len > 1 && input_conv.vc_type != CONV_NONE) | 1180 if (len > 1 && input_conv.vc_type != CONV_NONE) |
1177 len = convert_input(string2, len, sizeof(string2)); | 1181 len = convert_input(string2, len, sizeof(string2)); |