To: vim_dev@googlegroups.com Subject: Patch 9.0.0655 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.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. Files: src/term.c, src/proto/term.pro, src/os_unix.c, src/os_win32.c *** ../vim-9.0.0654/src/term.c 2022-10-03 20:24:35.730977235 +0100 --- src/term.c 2022-10-04 13:16:39.524426028 +0100 *************** *** 6734,6743 **** /* * Replace K_BS by and K_DEL by . * Returns "len" adjusted for replaced codes. */ int ! term_replace_bs_del_keycode(char_u *ta_buf, int ta_len, int len_arg) { int len = len_arg; int i; --- 6734,6744 ---- /* * Replace K_BS by and K_DEL by . + * Include any modifiers into the key and drop them. * Returns "len" adjusted for replaced codes. */ int ! term_replace_keycodes(char_u *ta_buf, int ta_len, int len_arg) { int len = len_arg; int i; *************** *** 6745,6757 **** for (i = ta_len; i < ta_len + len; ++i) { ! 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)); if (c == K_DEL || c == K_KDEL) ta_buf[i] = DEL; else --- 6746,6771 ---- for (i = ta_len; i < ta_len + len; ++i) { ! 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)); if (c == K_DEL || c == K_KDEL) ta_buf[i] = DEL; else *** ../vim-9.0.0654/src/proto/term.pro 2022-10-03 20:24:35.730977235 +0100 --- src/proto/term.pro 2022-10-04 13:16:45.052412417 +0100 *************** *** 86,90 **** 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); /* vim: set ft=c : */ --- 86,90 ---- 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_keycodes(char_u *ta_buf, int ta_len, int len_arg); /* vim: set ft=c : */ *** ../vim-9.0.0654/src/os_unix.c 2022-10-03 20:24:35.730977235 +0100 --- src/os_unix.c 2022-10-04 13:16:02.484517223 +0100 *************** *** 5106,5112 **** } } ! len = term_replace_bs_del_keycode(ta_buf, ta_len, len); /* * For pipes: echo the typed characters. --- 5106,5113 ---- } } ! // Remove Vim-specific codes from the input. ! len = term_replace_keycodes(ta_buf, ta_len, len); /* * For pipes: echo the typed characters. *** ../vim-9.0.0654/src/os_win32.c 2022-10-03 20:24:35.730977235 +0100 --- src/os_win32.c 2022-10-04 13:16:15.884484238 +0100 *************** *** 4531,4537 **** } } ! len = term_replace_bs_del_keycode(ta_buf, ta_len, len); /* * For pipes: echo the typed characters. For a pty this --- 4531,4537 ---- } } ! len = term_replace_keycodes(ta_buf, ta_len, len); /* * For pipes: echo the typed characters. For a pty this *** ../vim-9.0.0654/src/version.c 2022-10-03 22:10:32.599683973 +0100 --- src/version.c 2022-10-04 13:05:42.586035189 +0100 *************** *** 701,702 **** --- 701,704 ---- { /* Add new patch number below this line */ + /**/ + 655, /**/ -- hundred-and-one symptoms of being an internet addict: 270. You are subscribed to a mailing list for every piece of software you use. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// \\\ \\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///