]> granicus.if.org Git - vim/commitdiff
patch 8.2.3731: "set! termcap" shows codes in one column, but not keys v8.2.3731
authorBram Moolenaar <Bram@vim.org>
Fri, 3 Dec 2021 20:43:24 +0000 (20:43 +0000)
committerBram Moolenaar <Bram@vim.org>
Fri, 3 Dec 2021 20:43:24 +0000 (20:43 +0000)
Problem:    "set! termcap" shows codes in one column, but not keys.
Solution:   Also use one column for keys. (closes #9258)

src/option.c
src/proto/term.pro
src/term.c
src/testdir/test_set.vim
src/version.c

index 22dcfc5d1f1b5cf441b2f67a1dba561a6570f4d3..c6230c4027ffa95cecfa928230507e0c8d4086c2 100644 (file)
@@ -1218,11 +1218,12 @@ ex_set(exarg_T *eap)
  * 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_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,7 +1291,7 @@ do_set(
        else if (STRNCMP(arg, "termcap", 7) == 0 && !(opt_flags & OPT_MODELINE))
        {
            showoptions(2, opt_flags);
-           show_termcodes();
+           show_termcodes(opt_flags);
            did_show = TRUE;
            arg += 7;
        }
index 949b3500068eeaedb97ac7271244814dba284c12..6f0f08103aa5aa88d5c5ca0679fae98e9adc0806 100644 (file)
@@ -80,7 +80,7 @@ int check_termcode(int max_offset, char_u *buf, int bufsize, int *buflen);
 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);
+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);
index c20da0c336c7ed0994b065e6a17e8650adae2bbf..a8819a3ad96b08a2d9716009bc77fd9fb13f0a6d 100644 (file)
@@ -6217,9 +6217,10 @@ gather_termleader(void)
 /*
  * Show all termcodes (for ":set termcap")
  * This code looks a lot like showoptions(), but is different.
+ * "flags" can have OPT_ONECOLUMN.
  */
     void
-show_termcodes(void)
+show_termcodes(int flags)
 {
     int                col;
     int                *items;
@@ -6244,12 +6245,13 @@ show_termcodes(void)
     msg_puts_title(_("\n--- Terminal keys ---"));
 
     /*
-     * do the loop two times:
+     * 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 = 1; run <= 3 && !got_int; ++run)
+    for (run = (flags & OPT_ONECOLUMN) ? 3 : 1; run <= 3 && !got_int; ++run)
     {
        /*
         * collect the items in items[]
@@ -6259,9 +6261,10 @@ show_termcodes(void)
        {
            len = show_one_termcode(termcodes[i].name,
                                                    termcodes[i].code, FALSE);
-           if (len <= INC3 - GAP ? run == 1
+           if ((flags & OPT_ONECOLUMN) ||
+                   (len <= INC3 - GAP ? run == 1
                        : len <= INC2 - GAP ? run == 2
-                       : run == 3)
+                       : run == 3))
                items[item_count++] = i;
        }
 
index 7215772a001f9c0cee1869bad39138e627319079..4035248e108085d92e21f499d3472a396986aa32 100644 (file)
@@ -1,5 +1,7 @@
 " Tests for the :set command
 
+source check.vim
+
 function Test_set_backslash()
   let isk_save = &isk
 
@@ -45,4 +47,32 @@ func Test_set_no_arg()
   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
index d0057b3006913491e9338abca0e0f73bf142a9c2..5c822be96e5ec9bde6cb3021232f096c6db25ea9 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3731,
 /**/
     3730,
 /**/