]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.0655: passing modifier codes to a shell running in the GUI v9.0.0655
authorBram Moolenaar <Bram@vim.org>
Tue, 4 Oct 2022 12:17:31 +0000 (13:17 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 4 Oct 2022 12:17:31 +0000 (13:17 +0100)
Problem:    passing modifier codes to a shell running in the GUI. (Gary
            Johnson)
Solution:   Include modifier codes into the key and drop the modifiers.

src/os_unix.c
src/os_win32.c
src/proto/term.pro
src/term.c
src/version.c

index 20e979c1581147de9f22e860be5777a7a85e7db3..145f93f35bf53787b7d6e024b60f7b9b909a14a6 100644 (file)
@@ -5106,7 +5106,8 @@ mch_call_shell_fork(
                            }
                        }
 
-                       len = term_replace_bs_del_keycode(ta_buf, ta_len, len);
+                       // Remove Vim-specific codes from the input.
+                       len = term_replace_keycodes(ta_buf, ta_len, len);
 
                        /*
                         * For pipes: echo the typed characters.
index 644e64752137530d6ce48a9470648b25c76033ba..2a9d1cf57fd794d24981bd898eebe9250ceb1634 100644 (file)
@@ -4531,7 +4531,7 @@ mch_system_piped(char *cmd, int options)
                        }
                    }
 
-                   len = term_replace_bs_del_keycode(ta_buf, ta_len, len);
+                   len = term_replace_keycodes(ta_buf, ta_len, len);
 
                    /*
                     * For pipes: echo the typed characters.  For a pty this
index 13a093c882e40b37eea5b5739c8cd5cbefc17e55..7ce14b921a24b996446837314e0ea11664afbd89 100644 (file)
@@ -86,5 +86,5 @@ void update_tcap(int attr);
 void swap_tcap(void);
 void ansi_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
 void cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx);
-int term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len_arg);
+int term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg);
 /* vim: set ft=c : */
index c23b840d1fa64c1bc949aab155d3282a077e3e34..197af265cd661fef59fffbc4456f575c96ce9944 100644 (file)
@@ -6734,10 +6734,11 @@ cterm_color2rgb(int nr, char_u *r, char_u *g, char_u *b, char_u *ansi_idx)
 
 /*
  * Replace K_BS by <BS> and K_DEL by <DEL>.
+ * Include any modifiers into the key and drop them.
  * Returns "len" adjusted for replaced codes.
  */
     int
-term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len_arg)
+term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg)
 {
     int                len = len_arg;
     int                i;
@@ -6745,13 +6746,26 @@ term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len_arg)
 
     for (i = ta_len; i < ta_len + len; ++i)
     {
-       if (ta_buf[i] == CSI && len - i > 2)
+       if (ta_buf[i] == CSI && len - i > 3 && ta_buf[i + 1] == KS_MODIFIER)
+       {
+           int modifiers = ta_buf[i + 2];
+           int key = ta_buf[i + 3];
+
+           // Try to use the modifier to modify the key.  In any case drop the
+           // modifier.
+           mch_memmove(ta_buf + i + 1, ta_buf + i + 4, (size_t)(len - i - 3));
+           len -= 3;
+           if (key < 0x80)
+               key = merge_modifyOtherKeys(key, &modifiers);
+           ta_buf[i] = key;
+       }
+       else if (ta_buf[i] == CSI && len - i > 2)
        {
            c = TERMCAP2KEY(ta_buf[i + 1], ta_buf[i + 2]);
            if (c == K_DEL || c == K_KDEL || c == K_BS)
            {
                mch_memmove(ta_buf + i + 1, ta_buf + i + 3,
-                       (size_t)(len - i - 2));
+                                                       (size_t)(len - i - 2));
                if (c == K_DEL || c == K_KDEL)
                    ta_buf[i] = DEL;
                else
index f37aaf6820c3ed685ed0b3fe0066da59f660bfed..dc9b6bd4a6311510cea511ef4d67291c31c5747c 100644 (file)
@@ -699,6 +699,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    655,
 /**/
     654,
 /**/