summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2022-10-04 13:17:31 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-04 13:17:31 +0100
commit2f7e1b8b40dbc97752b8b816560f752f16e0207a (patch)
tree296d75367dc0067b123fdecec6f5aee4e814254a /src
parentec32c781a282398e3da27f4aec4b03fcd20f8b0d (diff)
patch 9.0.0655: passing modifier codes to a shell running in the GUIv9.0.0655
Problem: passing modifier codes to a shell running in the GUI. (Gary Johnson) Solution: Include modifier codes into the key and drop the modifiers.
Diffstat (limited to 'src')
-rw-r--r--src/os_unix.c3
-rw-r--r--src/os_win32.c2
-rw-r--r--src/proto/term.pro2
-rw-r--r--src/term.c20
-rw-r--r--src/version.c2
5 files changed, 23 insertions, 6 deletions
diff --git a/src/os_unix.c b/src/os_unix.c
index 20e979c158..145f93f35b 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -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.
diff --git a/src/os_win32.c b/src/os_win32.c
index 644e647521..2a9d1cf57f 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -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
diff --git a/src/proto/term.pro b/src/proto/term.pro
index 13a093c882..7ce14b921a 100644
--- a/src/proto/term.pro
+++ b/src/proto/term.pro
@@ -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 : */
diff --git a/src/term.c b/src/term.c
index c23b840d1f..197af265cd 100644
--- a/src/term.c
+++ b/src/term.c
@@ -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
diff --git a/src/version.c b/src/version.c
index f37aaf6820..dc9b6bd4a6 100644
--- a/src/version.c
+++ b/src/version.c
@@ -700,6 +700,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 655,
+/**/
654,
/**/
653,