To: vim_dev@googlegroups.com Subject: Patch 9.0.0974 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 9.0.0974 Problem: Even when Esc is encoded a timeout is used. Solution: Use K_ESC when an encoded Esc is found. Files: src/keymap.h, src/term.c, src/getchar.c *** ../vim-9.0.0973/src/keymap.h 2022-09-05 16:53:17.115566769 +0100 --- src/keymap.h 2022-11-29 20:07:11.635591906 +0000 *************** *** 278,290 **** , KE_SCRIPT_COMMAND = 104 // special key , KE_S_BS = 105 // shift + , KE_SID = 106 // special key, followed by {nr}; }; /* ! * the three byte codes are replaced with the following int when using vgetc() */ #define K_ZERO TERMCAP2KEY(KS_ZERO, KE_FILLER) #define K_UP TERMCAP2KEY('k', 'u') #define K_DOWN TERMCAP2KEY('k', 'd') #define K_LEFT TERMCAP2KEY('k', 'l') --- 278,293 ---- , KE_SCRIPT_COMMAND = 104 // special key , KE_S_BS = 105 // shift + , KE_SID = 106 // special key, followed by {nr}; + , KE_ESC = 107 // used for K_ESC }; /* ! * The three-byte codes are replaced with a negative number when using vgetc(). */ #define K_ZERO TERMCAP2KEY(KS_ZERO, KE_FILLER) + #define K_ESC TERMCAP2KEY(KS_EXTRA, KE_ESC) + #define K_UP TERMCAP2KEY('k', 'u') #define K_DOWN TERMCAP2KEY('k', 'd') #define K_LEFT TERMCAP2KEY('k', 'l') *************** *** 295,304 **** --- 298,309 ---- #define K_C_LEFT TERMCAP2KEY(KS_EXTRA, KE_C_LEFT) #define K_S_RIGHT TERMCAP2KEY('%', 'i') #define K_C_RIGHT TERMCAP2KEY(KS_EXTRA, KE_C_RIGHT) + #define K_S_HOME TERMCAP2KEY('#', '2') #define K_C_HOME TERMCAP2KEY(KS_EXTRA, KE_C_HOME) #define K_S_END TERMCAP2KEY('*', '7') #define K_C_END TERMCAP2KEY(KS_EXTRA, KE_C_END) + #define K_TAB TERMCAP2KEY(KS_EXTRA, KE_TAB) #define K_S_TAB TERMCAP2KEY('k', 'B') #define K_S_BS TERMCAP2KEY(KS_EXTRA, KE_S_BS) *** ../vim-9.0.0973/src/term.c 2022-11-29 18:32:29.305191264 +0000 --- src/term.c 2022-11-29 20:30:30.112340414 +0000 *************** *** 5121,5127 **** int *buflen) { char_u string[MAX_KEY_CODE_LEN + 1]; ! int new_slen = add_key_to_buf(arg[0], string); if (put_string_in_typebuf(offset, csi_len, string, new_slen, buf, bufsize, buflen) == FAIL) --- 5121,5139 ---- int *buflen) { char_u string[MAX_KEY_CODE_LEN + 1]; ! int new_slen; ! ! if (arg[0] == ESC) ! { ! // Putting Esc in the buffer creates ambiguity, it can be the start of ! // an escape sequence. Use K_ESC to avoid that. ! string[0] = K_SPECIAL; ! string[1] = KS_EXTRA; ! string[2] = KE_ESC; ! new_slen = 3; ! } ! else ! new_slen = add_key_to_buf(arg[0], string); if (put_string_in_typebuf(offset, csi_len, string, new_slen, buf, bufsize, buflen) == FAIL) *** ../vim-9.0.0973/src/getchar.c 2022-11-26 19:16:44.186717893 +0000 --- src/getchar.c 2022-11-29 20:27:30.639611910 +0000 *************** *** 1765,1770 **** --- 1765,1776 ---- } c = TO_SPECIAL(c2, c); + // K_ESC is used to avoid ambiguity with the single Esc + // character that might be the start of an escape sequence. + // Convert it back to a single Esc here. + if (c == K_ESC) + c = ESC; + #if defined(FEAT_GUI_MSWIN) && defined(FEAT_MENU) && defined(FEAT_TEAROFF) // Handle K_TEAROFF here, the caller of vgetc() doesn't need to // know that a menu was torn off *************** *** 3913,3918 **** --- 3919,3930 ---- continue; } c1 = TO_SPECIAL(c1, c2); + + // K_ESC is used to avoid ambiguity with the single Esc character + // that might be the start of an escape sequence. Convert it back + // to a single Esc here. + if (c1 == K_ESC) + c1 = ESC; } if (c1 == Ctrl_V) { *** ../vim-9.0.0973/src/version.c 2022-11-29 18:32:29.309191253 +0000 --- src/version.c 2022-11-29 20:05:41.243699984 +0000 *************** *** 697,698 **** --- 697,700 ---- { /* Add new patch number below this line */ + /**/ + 974, /**/ -- hundred-and-one symptoms of being an internet addict: 178. You look for an icon to double-click to open your bedroom window. /// 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 ///