]> granicus.if.org Git - vim/commitdiff
patch 8.2.1335: CTRL-C in the GUI doesn't interrupt v8.2.1335
authorBram Moolenaar <Bram@vim.org>
Sat, 1 Aug 2020 11:10:14 +0000 (13:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 1 Aug 2020 11:10:14 +0000 (13:10 +0200)
Problem:    CTRL-C in the GUI doesn't interrupt. (Sergey Vlasov)
Solution:   Recognize "C" with CTRL modifier as CTRL-C. (issue #6565)

src/gui.c
src/gui_gtk_x11.c
src/gui_photon.c
src/gui_x11.c
src/proto/gui.pro
src/version.c

index 4981d7331e4d55e2ed75d54da389b4309285edc7..e4745547dd6ea890fa76da6cae32203cb9e96033 100644 (file)
--- 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;
+}
+
index 40de6663135f89db05655114ecef3ba2fe80b29a..341db3d5a9abd7479af3a80c23e9b42692ed0e6c 100644 (file)
@@ -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)))
+    // 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);
index cdb5e15faf28f9dbe392bbc38a2a02d3c182c86f..12b0a3cdee5b6344cdb0d97579ed58e37e063c51 100644 (file)
@@ -596,11 +596,17 @@ gui_ph_handle_keyboard(PtWidget_t *widget, void *data, PtCallbackInfo_t *info)
            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)
index 26d02e77387a63e56aa781fd753ce095ddf6b528..1402407c2f286f3f0e292ced12e0c2719198ff52 100644 (file)
@@ -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);
index 51bddf90ebead24a5f58001cc34e10b79e95edc2..d76242026429c03da5e14eab0b1e225187632d63 100644 (file)
@@ -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 : */
index f65d0fe6e38d495cbac05144692d1808f748da55..931793ec7fe82b87b31ee226cb3937981e799e8b 100644 (file)
@@ -754,6 +754,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1335,
 /**/
     1334,
 /**/