To: vim_dev@googlegroups.com Subject: Patch 8.2.3731 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.2.3731 Problem: "set! termcap" shows codes in one column, but not keys. Solution: Also use one column for keys. (closes #9258) Files: src/option.c, src/term.c, src/proto/term.pro, src/testdir/test_set.vim *** ../vim-8.2.3730/src/option.c 2021-12-03 11:08:34.256842709 +0000 --- src/option.c 2021-12-03 20:18:52.019888823 +0000 *************** *** 1218,1228 **** * does not need to be expanded with option_expand(). * "opt_flags": * 0 for ":set" ! * OPT_GLOBAL for ":setglobal" ! * OPT_LOCAL for ":setlocal" and a modeline ! * OPT_MODELINE for a modeline ! * OPT_WINONLY to only set window-local options ! * OPT_NOWIN to skip setting window-local options * * returns FAIL if an error is detected, OK otherwise */ --- 1218,1229 ---- * does not need to be expanded with option_expand(). * "opt_flags": * 0 for ":set" ! * OPT_GLOBAL for ":setglobal" ! * OPT_LOCAL for ":setlocal" and a modeline ! * OPT_MODELINE for a modeline ! * OPT_WINONLY to only set window-local options ! * OPT_NOWIN to skip setting window-local options ! * OPT_ONECOLUMN do not use multiple columns * * returns FAIL if an error is detected, OK otherwise */ *************** *** 1290,1296 **** else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) { showoptions(2, opt_flags); ! show_termcodes(); did_show = TRUE; arg += 7; } --- 1291,1297 ---- else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE)) { showoptions(2, opt_flags); ! show_termcodes(opt_flags); did_show = TRUE; arg += 7; } *** ../vim-8.2.3730/src/term.c 2021-12-03 13:20:25.895976919 +0000 --- src/term.c 2021-12-03 20:43:01.664358432 +0000 *************** *** 6217,6225 **** /* * Show all termcodes (for ":set termcap") * This code looks a lot like showoptions(), but is different. */ void ! show_termcodes(void) { int col; int *items; --- 6217,6226 ---- /* * Show all termcodes (for ":set termcap") * This code looks a lot like showoptions(), but is different. + * "flags" can have OPT_ONECOLUMN. */ void ! show_termcodes(int flags) { int col; int *items; *************** *** 6244,6255 **** msg_puts_title(_("\n--- Terminal keys ---")); /* ! * do the loop two times: * 1. display the short items (non-strings and short strings) * 2. display the medium items (medium length strings) * 3. display the long items (remaining strings) */ ! for (run = 1; run <= 3 && !got_int; ++run) { /* * collect the items in items[] --- 6245,6257 ---- msg_puts_title(_("\n--- Terminal keys ---")); /* ! * Do the loop three times: * 1. display the short items (non-strings and short strings) * 2. display the medium items (medium length strings) * 3. display the long items (remaining strings) + * When "flags" has OPT_ONECOLUMN do everything in 3. */ ! for (run = (flags & OPT_ONECOLUMN) ? 3 : 1; run <= 3 && !got_int; ++run) { /* * collect the items in items[] *************** *** 6259,6267 **** { len = show_one_termcode(termcodes[i].name, termcodes[i].code, FALSE); ! if (len <= INC3 - GAP ? run == 1 : len <= INC2 - GAP ? run == 2 ! : run == 3) items[item_count++] = i; } --- 6261,6270 ---- { len = show_one_termcode(termcodes[i].name, termcodes[i].code, FALSE); ! if ((flags & OPT_ONECOLUMN) || ! (len <= INC3 - GAP ? run == 1 : len <= INC2 - GAP ? run == 2 ! : run == 3)) items[item_count++] = i; } *** ../vim-8.2.3730/src/proto/term.pro 2021-11-19 11:27:49.099056921 +0000 --- src/proto/term.pro 2021-12-03 20:23:38.683536744 +0000 *************** *** 80,86 **** void term_get_fg_color(char_u *r, char_u *g, char_u *b); void term_get_bg_color(char_u *r, char_u *g, char_u *b); char_u *replace_termcodes(char_u *from, char_u **bufp, int flags, int *did_simplify); ! void show_termcodes(void); int show_one_termcode(char_u *name, char_u *code, int printit); void update_tcap(int attr); void swap_tcap(void); --- 80,86 ---- void term_get_fg_color(char_u *r, char_u *g, char_u *b); void term_get_bg_color(char_u *r, char_u *g, char_u *b); char_u *replace_termcodes(char_u *from, char_u **bufp, int flags, int *did_simplify); ! void show_termcodes(int flags); int show_one_termcode(char_u *name, char_u *code, int printit); void update_tcap(int attr); void swap_tcap(void); *** ../vim-8.2.3730/src/testdir/test_set.vim 2021-07-12 20:43:15.921878554 +0100 --- src/testdir/test_set.vim 2021-12-03 20:42:02.060782461 +0000 *************** *** 1,5 **** --- 1,7 ---- " Tests for the :set command + source check.vim + function Test_set_backslash() let isk_save = &isk *************** *** 45,48 **** --- 47,78 ---- setglobal textwidth& endfunc + func Test_set_termcap() + CheckNotGui + + let lines = split(execute('set termcap'), "\n") + call assert_match('--- Terminal codes ---', lines[0]) + " four columns + call assert_match('t_..=.*t_..=.*t_..=.*t_..=', lines[1]) + + for keys_idx in range(len(lines)) + if lines[keys_idx] =~ '--- Terminal keys ---' + break + endif + endfor + call assert_true(keys_idx < len(lines)) + " three columns + call assert_match('t_.. .*t_.. .*t_.. ', lines[keys_idx + 1]) + + let more_lines = split(execute('set! termcap'), "\n") + for i in range(len(more_lines)) + if more_lines[i] =~ '--- Terminal keys ---' + break + endif + endfor + call assert_true(i < len(more_lines)) + call assert_true(i > keys_idx) + call assert_true(len(more_lines) - i > len(lines) - keys_idx) + endfunc + " vim: shiftwidth=2 sts=2 expandtab *** ../vim-8.2.3730/src/version.c 2021-12-03 19:24:38.159618697 +0000 --- src/version.c 2021-12-03 20:25:18.287419732 +0000 *************** *** 755,756 **** --- 755,758 ---- { /* Add new patch number below this line */ + /**/ + 3731, /**/ -- You can test a person's importance in the organization by asking how much RAM his computer has. Anybody who knows the answer to that question is not a decision-maker. (Scott Adams - The Dilbert principle) /// 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 ///