]> granicus.if.org Git - vim/commitdiff
patch 8.2.3864: cannot disable requesting key codes from xterm v8.2.3864
authorBram Moolenaar <Bram@vim.org>
Tue, 21 Dec 2021 09:12:23 +0000 (09:12 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 21 Dec 2021 09:12:23 +0000 (09:12 +0000)
Problem:    Cannot disable requesting key codes from xterm.
Solution:   Add the 'xtermcodes' option, default on.

runtime/doc/options.txt
runtime/doc/term.txt
runtime/optwin.vim
src/option.h
src/optiondefs.h
src/term.c
src/version.c

index a5ff937e080e92b01a639e36beb3a4099e7d8103..3e71ba14e50092b796344f9d3dd9ca4449a9ec07 100644 (file)
@@ -9206,4 +9206,16 @@ A jump table for the options with a short description can be found at |Q_op|.
        screen.  When non-zero, characters are sent to the terminal one by
        one.  For debugging purposes.
 
+                                          *'xtermcodes'* *'noxtermcodes'*
+'xtermcodes'           boolean (default on)
+                       global
+       When detecting xterm patchlevel 141 or higher with the termresponse
+       mechanism and this option is set, Vim will request the actual termimal
+       key codes and number of colors from the terminal.  This takes care of
+       various configuration options of the terminal that cannot be obtained
+       from the termlib/terminfo entry, see |xterm-codes|.
+       A side effect may be that t_Co changes and Vim will redraw the
+       display.
+
+
  vim:tw=78:ts=8:noet:ft=help:norl:
index 8862d0a4006b01b4d627df973ed93b87b4b2434c..3e90cc0476617b36e06a15040fa071cfb1631784 100644 (file)
@@ -556,8 +556,15 @@ request the key codes directly from the xterm.  The responses are used to
 adjust the various t_ codes.  This avoids the problem that the xterm can
 produce different codes, depending on the mode it is in (8-bit, VT102,
 VT220, etc.).  The result is that codes like <xF1> are no longer needed.
-Note: This is only done on startup.  If the xterm options are changed after
-Vim has started, the escape sequences may not be recognized anymore.
+
+One of the codes that can change is 't_Co', the number of colors.  This will
+trigger a redraw.  If this is a problem, reset the 'xtermcodes' option as
+early as possible: >
+       set noxtermcodes
+
+Note: Requesting the key codes is only done on startup.  If the xterm options
+are changed after Vim has started, the escape sequences may not be recognized
+anymore.
 
                                                        *xterm-true-color*
 Vim supports using true colors in the terminal (taken from |highlight-guifg|
index 17fe2763763aa66b2e36f9c9bf479a14e7ca4d82..9aa2db26f44989991958bba3b304b7f72645baf0 100644 (file)
@@ -562,14 +562,22 @@ endif
 call <SID>Header(gettext("terminal"))
 call <SID>AddOption("term", gettext("name of the used terminal"))
 call <SID>OptionG("term", &term)
+
 call <SID>AddOption("ttytype", gettext("alias for 'term'"))
 call <SID>OptionG("tty", &tty)
+
 call <SID>AddOption("ttybuiltin", gettext("check built-in termcaps first"))
 call <SID>BinOptionG("tbi", &tbi)
+
 call <SID>AddOption("ttyfast", gettext("terminal connection is fast"))
 call <SID>BinOptionG("tf", &tf)
+
+call <SID>AddOption("xtermcodes", gettext("request terminal key codes when an xterm is detected"))
+call <SID>BinOptionG("xtermcodes", &xtermcodes)
+
 call <SID>AddOption("weirdinvert", gettext("terminal that requires extra redrawing"))
 call <SID>BinOptionG("wiv", &wiv)
+
 call <SID>AddOption("esckeys", gettext("recognize keys that start with <Esc> in Insert mode"))
 call <SID>BinOptionG("ek", &ek)
 call <SID>AddOption("scrolljump", gettext("minimal number of lines to scroll at a time"))
index 49d869bfc72ccc5ab1cf6fa91aab1a8851617b41..a82258e3ab7da05a9521b3f8b6de2c255c419e45 100644 (file)
@@ -485,6 +485,7 @@ EXTERN int  p_deco;         // 'delcombine'
 #ifdef FEAT_EVAL
 EXTERN char_u  *p_ccv;         // 'charconvert'
 #endif
+EXTERN int     p_cdh;          // 'cdhome'
 EXTERN char_u  *p_cino;        // 'cinoptions'
 #ifdef FEAT_CMDWIN
 EXTERN char_u  *p_cedit;       // 'cedit'
@@ -1094,7 +1095,7 @@ EXTERN int        p_write;        // 'write'
 EXTERN int     p_wa;           // 'writeany'
 EXTERN int     p_wb;           // 'writebackup'
 EXTERN long    p_wd;           // 'writedelay'
-EXTERN int     p_cdh;          // 'cdhome'
+EXTERN int     p_xtermcodes;   // 'xtermcodes'
 
 /*
  * "indir" values for buffer-local options.
index c39244288b56e13c2f5e369f94af61e00d924417..cc4ad9e57e684e6f051a22723dfabc16b689f855 100644 (file)
@@ -2941,6 +2941,9 @@ static struct vimoption options[] =
     {"writedelay",  "wd",   P_NUM|P_VI_DEF,
                            (char_u *)&p_wd, PV_NONE,
                            {(char_u *)0L, (char_u *)0L} SCTX_INIT},
+    {"xtermcodes",  NULL,   P_BOOL|P_VI_DEF,
+                           (char_u *)&p_xtermcodes, PV_NONE,
+                           {(char_u *)TRUE, (char_u *)0L} SCTX_INIT},
 
 // terminal output codes
 #define p_term(sss, vvv)   {sss, NULL, P_STRING|P_VI_DEF|P_RALL|P_SECURE, \
index f74b18add9ecf6950792b034a2fa911b9cabcb49..e97ec2c4d58caa7239e28a871f751150ed9e661a 100644 (file)
@@ -4694,7 +4694,7 @@ handle_version_response(int first, int *arg, int argc, char_u *tp)
 
        // If xterm version >= 141 try to get termcap codes.  For other
        // terminals the request should be ignored.
-       if (version >= 141)
+       if (version >= 141 && p_xtermcodes)
        {
            LOG_TR(("Enable checking for XT codes"));
            check_for_codes = TRUE;
@@ -6446,8 +6446,7 @@ got_code_from_term(char_u *code, int len)
            if (name[0] == 'C' && name[1] == 'o')
            {
                // Color count is not a key code.
-               i = atoi((char *)str);
-               may_adjust_color_count(i);
+               may_adjust_color_count(atoi((char *)str));
            }
            else
            {
index 586d2ec635f56f29a1828c8ff751cf3d7352496e..bbb21576e5412c99f17e50a0dcd8163b2e474a8c 100644 (file)
@@ -749,6 +749,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    3864,
 /**/
     3863,
 /**/