changeset 21570:f260c1411833 v8.2.1335

patch 8.2.1335: CTRL-C in the GUI doesn't interrupt Commit: https://github.com/vim/vim/commit/4e1d8bd79b87b120bd40afe0eba54a419f8c3aee Author: Bram Moolenaar <Bram@vim.org> Date: Sat Aug 1 13:10:14 2020 +0200 patch 8.2.1335: CTRL-C in the GUI doesn't interrupt Problem: CTRL-C in the GUI doesn't interrupt. (Sergey Vlasov) Solution: Recognize "C" with CTRL modifier as CTRL-C. (issue https://github.com/vim/vim/issues/6565)
author Bram Moolenaar <Bram@vim.org>
date Sat, 01 Aug 2020 13:15:04 +0200
parents bbb0e366528f
children c561ab810dcd
files src/gui.c src/gui_gtk_x11.c src/gui_photon.c src/gui_x11.c src/proto/gui.pro src/version.c
diffstat 6 files changed, 53 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/gui.c
+++ b/src/gui.c
@@ -5575,3 +5575,24 @@ gui_handle_drop(
     entered = FALSE;
 }
 #endif
+
+/*
+ * Check if "key" is to interrupt us.  Handles a key that has not had modifiers
+ * applied yet.
+ * Return the key with modifiers applied if so, NUL if not.
+ */
+    int
+check_for_interrupt(int key, int modifiers_arg)
+{
+    int modifiers = modifiers_arg;
+    int c = merge_modifyOtherKeys(key, &modifiers);
+
+    if ((c == Ctrl_C && ctrl_c_interrupts)
+	    || (intr_char != Ctrl_C && c == intr_char))
+    {
+	got_int = TRUE;
+	return c;
+    }
+    return NUL;
+}
+
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -1254,11 +1254,16 @@ key_press_event(GtkWidget *widget UNUSED
 	add_to_input_buf(string2, 3);
     }
 
-    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
-		   || (string[0] == intr_char && intr_char != Ctrl_C)))
-    {
-	trash_input_buf();
-	got_int = TRUE;
+    // Check if the key interrupts.
+    {
+	int int_ch = check_for_interrupt(key, modifiers);
+
+	if (int_ch != NUL)
+	{
+	    trash_input_buf();
+	    string[0] = int_ch;
+	    len = 1;
+	}
     }
 
     add_to_input_buf(string, len);
--- a/src/gui_photon.c
+++ b/src/gui_photon.c
@@ -596,11 +596,17 @@ gui_ph_handle_keyboard(PtWidget_t *widge
 	    string[ len++ ] = ch;
 	}
 
-	if (len == 1 && ((ch == Ctrl_C && ctrl_c_interrupts)
-							  || ch == intr_char))
+	// Check if the key interrupts.
 	{
-	    trash_input_buf();
-	    got_int = TRUE;
+	    int int_ch = check_for_interrupt(ch, modifiers);
+
+	    if (int_ch != NUL)
+	    {
+		ch = int_ch;
+		string[0] = ch;
+		len = 1;
+		trash_input_buf();
+	    }
 	}
 
 	if (len == 1 && string[0] == CSI)
--- a/src/gui_x11.c
+++ b/src/gui_x11.c
@@ -970,14 +970,16 @@ gui_x11_key_hit_cb(
 	add_to_input_buf(string2, 3);
     }
 
-    if (len == 1 && ((string[0] == Ctrl_C && ctrl_c_interrupts)
-#ifdef UNIX
-	    || (intr_char != 0 && string[0] == intr_char)
-#endif
-	    ))
+    // Check if the key interrupts.
     {
-	trash_input_buf();
-	got_int = TRUE;
+	int int_ch = check_for_interrupt(key, modifiers);
+
+	if (int_ch != NUL)
+	{
+	    trash_input_buf();
+	    string[0] = int_ch;
+	    len = 1;
+	}
     }
 
     add_to_input_buf(string, len);
--- a/src/proto/gui.pro
+++ b/src/proto/gui.pro
@@ -65,4 +65,5 @@ void gui_update_screen(void);
 char_u *get_find_dialog_text(char_u *arg, int *wwordp, int *mcasep);
 int gui_do_findrepl(int flags, char_u *find_text, char_u *repl_text, int down);
 void gui_handle_drop(int x, int y, int_u modifiers, char_u **fnames, int count);
+int check_for_interrupt(int key, int modifiers_arg);
 /* vim: set ft=c : */
--- 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 */
 /**/
+    1335,
+/**/
     1334,
 /**/
     1333,