]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.1703: Cannot react to terminal OSC responses v9.1.1703
authorFoxe Chen <chen.foxe@gmail.com>
Wed, 27 Aug 2025 19:15:47 +0000 (21:15 +0200)
committerChristian Brabandt <cb@256bit.org>
Wed, 27 Aug 2025 19:15:47 +0000 (21:15 +0200)
Problem:  Cannot react to terminal OSC responses
Solution: Allow TermResponseAll to be triggered by Terminal OSC
          responses (Foxe Chen)

fixes: #14995
closes: #17975

Signed-off-by: Foxe Chen <chen.foxe@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
30 files changed:
runtime/doc/autocmd.txt
runtime/doc/eval.txt
runtime/doc/options.txt
runtime/doc/tags
runtime/doc/version9.txt
runtime/optwin.vim
runtime/plugin/README.txt
runtime/plugin/colorresp.vim [new file with mode: 0644]
runtime/syntax/vim.vim
src/errors.h
src/evalvars.c
src/getchar.c
src/main.c
src/option.c
src/option.h
src/optiondefs.h
src/po/vim.pot
src/proto/evalvars.pro
src/proto/option.pro
src/proto/term.pro
src/proto/time.pro
src/structs.h
src/term.c
src/testdir/Make_all.mak
src/testdir/test_plugin_colorresp.vim [new file with mode: 0644]
src/testdir/test_termcodes.vim
src/testdir/util/gen_opt_test.vim
src/time.c
src/version.c
src/vim.h

index 69f28b95e060d78d890dd4ab38f33ad1afa7b12c..37b3e3509c17d23656e2acaa2f6d1b40f0eb93f7 100644 (file)
@@ -1306,22 +1306,32 @@ TermResponse                    After the response to |t_RV| is received from
                                takes time is involved.
                                                        *TermResponseAll*
 TermResponseAll                        After the response to |t_RV|, |t_RC|, |t_RS|,
-                               |t_RB|, |t_RF|, or |t_u7| are received from
+                               |t_u7| or any OSC command are received from
                                the terminal.  The value of |v:termresponse|,
                                |v:termblinkresp|, |v:termstyleresp|,
-                               |v:termrbgresp|, |v:termrfgresp|, and
-                               |v:termu7resp|, correspondingly, can be used.
-                               <amatch> will be set to any of:
+                               |v:termu7resp|, and |v:termosc|
+                               correspondingly, can be used.  <amatch> will
+                               be set to any of:
                                    "version",
                                    "cursorblink",
                                    "cursorshape",
-                                   "background",
-                                   "foreground",
                                    "ambiguouswidth"
+                                   "osc"
                                Note that this event may be triggered halfway
                                executing another event, especially if file I/O,
                                a shell command or anything else that takes time
                                is involved.
+                               Note: Traditionally, TermResponseAll was also
+                               used for "foreground" and "background"
+                               patterns.  These are now handled as part of
+                               the "osc" value.  For backwards compatibility,
+                               the $VIMRUNTIME/plugin/colorresp.vim plugin
+                               will handle "osc" events and emit
+                               TermResponseAll autocommand events when it
+                               encounters "foreground" and "background"
+                               values.
+
+
                                                        *TextChanged*
 TextChanged                    After a change was made to the text in the
                                current buffer in Normal mode.  That is after
index c13e3a0b79be1b34345fdb062690ced88beb0649..d2344692a23f4db392ec9fd85ec0929bf972267e 100644 (file)
@@ -1,4 +1,4 @@
-*eval.txt*     For Vim version 9.1.  Last change: 2025 Aug 23
+*eval.txt*     For Vim version 9.1.  Last change: 2025 Aug 27
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -2893,16 +2893,15 @@ v:termstyleresp The escape sequence returned by the terminal for the |t_RS|
                                                *v:termrbgresp*
 v:termrbgresp  The escape sequence returned by the terminal for the |t_RB|
                termcap entry.  This is used to find out what the terminal
-               background color is; see 'background'.  When this option is
-               set, the TermResponseAll autocommand event is fired, with
-               <amatch> set to "background".
+               background color is; see 'background'.  This is set by the
+               $VIMRUNTIME/plugin/colorresp.vim plugin normally included with
+               Vim, but can be set manually if you know what you are doing.
+               Note that changing this will not do anything.
 
                                                *v:termrfgresp*
 v:termrfgresp  The escape sequence returned by the terminal for the |t_RF|
                termcap entry.  This is used to find out what the terminal
-               foreground color is.  When this option is set, the
-               TermResponseAll autocommand event is fired, with <amatch> set
-               to "foreground".
+               foreground color is. Behaves the same as |v:termrbgresp|
 
                                                *v:termu7resp*
 v:termu7resp   The escape sequence returned by the terminal for the |t_u7|
@@ -2917,6 +2916,14 @@ v:termda1        The escape sequence returned by a primary device attributes
                TermResponseAll autocommand event is fired, with <amatch> set
                to "da1".  Can be used to detect OSC 52 support in a terminal.
 
+                                               *v:termosc*
+v:termosc      The escape sequence of the most recent OSC response received
+               from the terminal.  When this option is set, the
+               |TermResponseAll| autocommand event is fired, with <amatch>
+               set to "osc".  Also used to set the |v:termrbgresp| and
+               |v:termrfgresp| via the $VIMRUNTIME/plugin/colorresp.vim
+               plugin
+
                                        *v:testing* *testing-variable*
 v:testing      Must be set before using `test_garbagecollect_now()`.
                Also, when set certain error messages won't be shown for 2
index 47032676024defee973ee9ccc5f0e3a96d0673f0..d671a25ea5badbde65568abfb0e3d3b70e17af87 100644 (file)
@@ -6448,6 +6448,14 @@ A jump table for the options with a short description can be found at |Q_op|.
        This option cannot be set from a |modeline| or in the |sandbox|, for
        security reasons.
 
+                                       *'osctimeoutlen'* *'ost'* *E1568*
+'osctimeoutlen' 'ost'  number (default 1000)
+                       global
+       This option specifies the timeout in milliseconds Vim should wait
+       until it receives an OSC terminator after receiving the beginning of
+       an OSC command response. See the |TermResponseAll| autocommand event
+       and |v:termosc| for more information.
+
                                        *'osfiletype'* *'oft'*
 'osfiletype' 'oft'     string (default: "")
                        local to buffer
index 72d2727aff42af9ed240a2a44ddbeddc2f84c83a..3a4a07bf029e7586c2e718ac0f73851178338348 100644 (file)
@@ -845,7 +845,9 @@ $quote      eval.txt        /*$quote*
 'opfunc'       options.txt     /*'opfunc'*
 'optimize'     vi_diff.txt     /*'optimize'*
 'option'       intro.txt       /*'option'*
+'osctimeoutlen'        options.txt     /*'osctimeoutlen'*
 'osfiletype'   options.txt     /*'osfiletype'*
+'ost'  options.txt     /*'ost'*
 'pa'   options.txt     /*'pa'*
 'packpath'     options.txt     /*'packpath'*
 'para' options.txt     /*'para'*
@@ -4723,6 +4725,7 @@ E1564     remote.txt      /*E1564*
 E1565  remote.txt      /*E1565*
 E1566  remote.txt      /*E1566*
 E1567  remote.txt      /*E1567*
+E1568  options.txt     /*E1568*
 E157   sign.txt        /*E157*
 E158   sign.txt        /*E158*
 E159   sign.txt        /*E159*
@@ -11280,6 +11283,7 @@ v:t_tuple       eval.txt        /*v:t_tuple*
 v:t_typealias  eval.txt        /*v:t_typealias*
 v:termblinkresp        eval.txt        /*v:termblinkresp*
 v:termda1      eval.txt        /*v:termda1*
+v:termosc      eval.txt        /*v:termosc*
 v:termrbgresp  eval.txt        /*v:termrbgresp*
 v:termresponse eval.txt        /*v:termresponse*
 v:termrfgresp  eval.txt        /*v:termrfgresp*
index 7e18266d7b5e108990a34bb1925c958e42239267..6be0977224994ac2e67fd06d08066c565b106693 100644 (file)
@@ -41753,6 +41753,10 @@ Others: ~
 - |CmdlineLeave| sets |v:char| to the character that caused exiting the
   Command-line.
 - |min()|/|max()| can handle all comparable data types.
+- Vim triggers the |TermResponseAll| autocommand for any terminal OSC value.
+- Vim includes the $VIMRUNTIME/plugins/colorresp.vim which parses the terminal
+  OSC response and can trigger a |TermResponseAll| with the "background" or
+  "foreground" value.
 
 Platform specific ~
 - MS-Winodws: Paths like "\Windows" and "/Windows" are now considered to be
index 578b6099718c235e0a046b905152789cde9dcf1f..9c706dce712c7cf227d43e8ab236231c88b3e28a 100644 (file)
@@ -632,7 +632,8 @@ if has("win32")
   call <SID>AddOption("restorescreen", gettext("restore the screen contents when exiting Vim"))
   call <SID>BinOptionG("rs", &rs)
 endif
-
+call <SID>AddOption("osctimeoutlen", gettext("timeout used for terminal OSC responses"))
+call <SID>OptionG("ost", &ost)
 
 call <SID>Header(gettext("using the mouse"))
 call <SID>AddOption("mouse", gettext("list of flags for using the mouse"))
index 11bf1e97b27746504e7069fb9c36fa4742bb0262..e4f3c1b708c50dc737bbdbb1b3f69efc842502fa 100644 (file)
@@ -3,6 +3,7 @@ The plugin directory is for standard Vim plugin scripts.
 All files here ending in .vim will be sourced by Vim when it starts up.
 Look in the file for hints on how it can be disabled without deleting it.
 
+colorresp.vim       used to detect terminal background and foreground colours
 getscriptPlugin.vim  get latest version of Vim scripts
 gzip.vim            edit compressed files
 logiPat.vim         logical operators on patterns
@@ -15,7 +16,3 @@ tarPlugin.vim      edit (compressed) tar files
 tohtml.vim          convert a file with syntax highlighting to HTML
 vimballPlugin.vim    create and unpack .vba files
 zipPlugin.vim       edit zip archives
-
-Note: the explorer.vim plugin is no longer here, the netrw.vim plugin has
-taken over browsing directories (also for remote directories).
-
diff --git a/runtime/plugin/colorresp.vim b/runtime/plugin/colorresp.vim
new file mode 100644 (file)
index 0000000..f597dc7
--- /dev/null
@@ -0,0 +1,51 @@
+vim9script
+
+# Vim plugin for setting the background and foreground colours depending on
+# the terminal response.
+#
+# Maintainer:  The Vim Project <https://github.com/vim/vim>
+# Last Change: 2025 August 13
+
+if exists("loaded_colorresp")
+  finish
+endif
+g:loaded_colorresp = 1
+
+augroup ColorResp
+  au!
+  au TermResponseAll osc {
+    var parts: list<string> = matchlist(v:termosc, '\(\d\+\);rgb:\(\w\+\)/\(\w\+\)/\(\w\+\)')
+    if len(parts) >= 5
+      var type: string = parts[1]
+      var rval: number = str2nr(parts[2][: 1], 16)
+      var gval: number = str2nr(parts[3][: 1], 16)
+      var bval: number = str2nr(parts[4][: 1], 16)
+
+      if type == '11'
+        # Detect light or dark background by parsing OSC 11 RGB background reply
+        # from terminal. Sum the RGB values roughly; if bright enough, set
+        # 'background' to 'light', otherwise set it to 'dark'.
+        var new_bg_val: string = (3 * char2nr('6') < char2nr(parts[2]) + char2nr(parts[3]) + char2nr(parts[4])) ? "light" : "dark"
+
+        v:termrbgresp = v:termosc
+        &background = new_bg_val
+        # For backwards compatibility
+        if exists('#TermResponseAll#background')
+          doautocmd <nomodeline> TermResponseAll background
+        endif
+      else
+        v:termrfgresp = v:termosc
+        # For backwards compatibility
+        if exists('#TermResponseAll#foreground')
+          doautocmd <nomodeline> TermResponseAll foreground
+        endif
+      endif
+    endif
+  }
+  au VimEnter * ++once {
+    call echoraw(&t_RB)
+    call echoraw(&t_RF)
+  }
+augroup END
+
+# vim: set sw=2 sts=2 :
index 4161ee9550816c7e2b1964eec135a729526ff8ee..b0465918b65ceda8437cd7b8713b8a03bd0f4867 100644 (file)
@@ -2,7 +2,7 @@
 " Language:       Vim script
 " Maintainer:     Hirohito Higashi <h.east.727 ATMARK gmail.com>
 "         Doug Kearns <dougkearns@gmail.com>
-" Last Change:    2025 Aug 23
+" Last Change:    2025 Aug 27
 " Former Maintainer: Charles E. Campbell
 
 " DO NOT CHANGE DIRECTLY.
@@ -63,15 +63,15 @@ syn keyword vimStdPlugin contained  Arguments Asm Break Cfilter Clear Continue Di
 
 " vimOptions are caught only when contained in a vimSet {{{2
 " GEN_SYN_VIM: vimOption normal, START_STR='syn keyword vimOption contained', END_STR='skipwhite nextgroup=vimSetEqual,vimSetMod'
-syn keyword vimOption contained al aleph ari allowrevins ambw ambiwidth arab arabic arshape arabicshape acd autochdir ac autocomplete acl autocompletedelay act autocompletetimeout ai autoindent ar autoread asd autoshelldir aw autowrite awa autowriteall bg background bs backspace bk backup bkc backupcopy bdir backupdir bex backupext bsk backupskip bdlay balloondelay beval ballooneval bevalterm balloonevalterm bexpr balloonexpr bo belloff bin binary bomb brk breakat bri breakindent briopt breakindentopt bsdir browsedir bh bufhidden bl buflisted bt buftype cmp casemap cdh cdhome cd cdpath cedit ccv charconvert chi chistory cin cindent cink cinkeys cino cinoptions cinsd cinscopedecls cinw cinwords cb clipboard cpm clipmethod ch cmdheight cwh cmdwinheight cc colorcolumn co columns com comments cms commentstring skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained cp compatible cpt complete cto completetimeout cfu completefunc cfc completefuzzycollect cia completeitemalign cot completeopt cpp completepopup csl completeslash cocu concealcursor cole conceallevel cf confirm ci copyindent cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg csqf cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder csverb cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt cursorlineopt debug def define deco delcombine dict dictionary diff dia diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline ea equalalways ep equalprg eb errorbells ef errorfile efm errorformat ek esckeys ei eventignore skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained eiw eventignorewin et expandtab ex exrc fenc fileencoding fencs fileencodings ff fileformat ffs fileformats fic fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight hlg helplang hid hidden hl highlight hi history hk hkmap hkp hkmapp hls hlsearch skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained icon iconstring ic ignorecase imaf imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg mps matchpairs mat matchtime mco maxcombine mfd maxfuncdepth mmd maxmapdepth mm maxmem skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained mmp maxmempattern mmt maxmemtot msc maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse mousef mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc operatorfunc pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev printdevice penc printencoding pexpr printexpr pfn printfont pheader printheader pmbcs printmbcharset pmbfn printmbfont popt printoptions prompt ph pumheight skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained pmw pummaxwidth pw pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap rop renderoptions report rs restorescreen ri revins rl rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc sft showfulltag skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained sm showmatch smd showmode stal showtabline stpl showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si smartindent sta smarttab sms smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt termwintype terse skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight wmh winminheight skipwhite nextgroup=vimSetEqual,vimSetMod
-syn keyword vimOption contained wmw winminwidth winptydll wiw winwidth wse wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay xtermcodes skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained al aleph ari allowrevins ambw ambiwidth arab arabic arshape arabicshape acd autochdir ac autocomplete acl autocompletedelay act autocompletetimeout ai autoindent ar autoread asd autoshelldir aw autowrite awa autowriteall bg background bs backspace bk backup bkc backupcopy bdir backupdir bex backupext bsk backupskip bdlay balloondelay beval ballooneval bevalterm balloonevalterm bexpr balloonexpr bo belloff bin binary bomb brk breakat bri breakindent briopt breakindentopt bsdir browsedir bh bufhidden bl buflisted bt buftype cmp casemap cdh cdhome cd cdpath cedit ccv charconvert chi chistory cin cindent cink cinkeys cino cinoptions cinsd cinscopedecls cinw cinwords cb clipboard cpm clipmethod ch cmdheight cwh cmdwinheight cc colorcolumn skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained co columns com comments cms commentstring cp compatible cpt complete cfu completefunc cfc completefuzzycollect cia completeitemalign cot completeopt cpp completepopup csl completeslash cto completetimeout cocu concealcursor cole conceallevel cf confirm ci copyindent cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg csqf cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder csverb cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt cursorlineopt debug def define deco delcombine dict dictionary diff dia diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline ea equalalways ep equalprg eb errorbells skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained ef errorfile efm errorformat ek esckeys ei eventignore eiw eventignorewin et expandtab ex exrc fenc fileencoding fencs fileencodings ff fileformat ffs fileformats fic fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight hlg helplang hid hidden skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained hl highlight hi history hk hkmap hkp hkmapp hls hlsearch icon iconstring ic ignorecase imaf imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg mps matchpairs mat matchtime skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained mco maxcombine mfd maxfuncdepth mmd maxmapdepth mm maxmem mmp maxmempattern mmt maxmemtot msc maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse mousef mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc operatorfunc ost osctimeoutlen pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev printdevice penc printencoding pexpr printexpr pfn printfont pheader printheader skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained pmbcs printmbcharset pmbfn printmbfont popt printoptions prompt ph pumheight pmw pummaxwidth pw pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap rop renderoptions report rs restorescreen ri revins rl rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw shiftwidth shm shortmess skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained sn shortname sbr showbreak sc showcmd sloc showcmdloc sft showfulltag sm showmatch smd showmode stal showtabline stpl showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si smartindent sta smarttab sms smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding tgc termguicolors skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained twk termwinkey twsl termwinscroll tws termwinsize twt termwintype terse ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr wincolor wi window skipwhite nextgroup=vimSetEqual,vimSetMod
+syn keyword vimOption contained wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight wmh winminheight wmw winminwidth winptydll wiw winwidth wse wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay xtermcodes skipwhite nextgroup=vimSetEqual,vimSetMod
 
 " vimOptions: These are the turn-off setting variants {{{2
 " GEN_SYN_VIM: vimOption turn-off, START_STR='syn keyword vimOption contained', END_STR=''
@@ -102,16 +102,15 @@ syn match   vimOption contained   "t_k;"
 
 " vimOptions: These are the variable names {{{2
 " GEN_SYN_VIM: vimOption normal variable,           START_STR='syn keyword vimOptionVarName contained', END_STR=''
-syn keyword vimOptionVarName contained al aleph ari allowrevins ambw ambiwidth arab arabic arshape arabicshape acd autochdir ac autocomplete acl autocompletedelay act autocompletetimeout ai autoindent ar autoread asd autoshelldir aw autowrite awa autowriteall bg background bs backspace bk backup bkc backupcopy bdir backupdir bex backupext bsk backupskip bdlay balloondelay beval ballooneval bevalterm balloonevalterm bexpr balloonexpr bo belloff bin binary bomb brk breakat bri breakindent briopt breakindentopt bsdir browsedir bh bufhidden bl buflisted bt buftype cmp casemap cdh cdhome cd cdpath cedit ccv charconvert chi chistory cin cindent cink cinkeys cino cinoptions cinsd cinscopedecls cinw cinwords cb clipboard cpm clipmethod ch cmdheight cwh cmdwinheight cc colorcolumn co columns com comments cms commentstring
-syn keyword vimOptionVarName contained cp compatible cpt complete cto completetimeout cfu completefunc cfc completefuzzycollect cia completeitemalign cot completeopt cpp completepopup csl completeslash cocu concealcursor cole conceallevel cf confirm ci copyindent cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg csqf cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder csverb cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt cursorlineopt debug def define deco delcombine dict dictionary diff dia diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline ea equalalways ep equalprg eb errorbells ef errorfile efm errorformat ek esckeys ei eventignore
-syn keyword vimOptionVarName contained eiw eventignorewin et expandtab ex exrc fenc fileencoding fencs fileencodings ff fileformat ffs fileformats fic fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight hlg helplang hid hidden hl highlight hi history hk hkmap hkp hkmapp hls hlsearch
-syn keyword vimOptionVarName contained icon iconstring ic ignorecase imaf imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg mps matchpairs mat matchtime mco maxcombine mfd maxfuncdepth mmd maxmapdepth
-syn keyword vimOptionVarName contained mm maxmem mmp maxmempattern mmt maxmemtot msc maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse mousef mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc operatorfunc pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev printdevice penc printencoding pexpr printexpr pfn printfont pheader printheader pmbcs printmbcharset pmbfn printmbfont popt printoptions prompt
-syn keyword vimOptionVarName contained ph pumheight pmw pummaxwidth pw pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap rop renderoptions report rs restorescreen ri revins rl rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp shelltemp st shelltype sxe shellxescape sxq shellxquote sr shiftround sw shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc
-syn keyword vimOptionVarName contained sft showfulltag sm showmatch smd showmode stal showtabline stpl showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si smartindent sta smarttab sms smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term tbidi termbidi tenc termencoding tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize
-syn keyword vimOptionVarName contained twt termwintype terse ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu wim wildmode wop wildoptions wak winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth
-syn keyword vimOptionVarName contained wh winheight wmh winminheight wmw winminwidth winptydll wiw winwidth wse wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay xtermcodes
-
+syn keyword vimOptionVarName contained al aleph ari allowrevins ambw ambiwidth arab arabic arshape arabicshape acd autochdir ac autocomplete acl autocompletedelay act autocompletetimeout ai autoindent ar autoread asd autoshelldir aw autowrite awa autowriteall bg background bs backspace bk backup bkc backupcopy bdir backupdir bex backupext bsk backupskip bdlay balloondelay beval ballooneval bevalterm balloonevalterm bexpr balloonexpr bo belloff bin binary bomb brk breakat bri breakindent briopt breakindentopt bsdir browsedir bh bufhidden bl buflisted bt buftype cmp casemap cdh cdhome cd cdpath cedit ccv charconvert chi chistory cin cindent cink cinkeys cino cinoptions cinsd cinscopedecls cinw cinwords cb clipboard cpm clipmethod ch cmdheight cwh cmdwinheight cc colorcolumn
+syn keyword vimOptionVarName contained co columns com comments cms commentstring cp compatible cpt complete cfu completefunc cfc completefuzzycollect cia completeitemalign cot completeopt cpp completepopup csl completeslash cto completetimeout cocu concealcursor cole conceallevel cf confirm ci copyindent cpo cpoptions cm cryptmethod cspc cscopepathcomp csprg cscopeprg csqf cscopequickfix csre cscoperelative cst cscopetag csto cscopetagorder csverb cscopeverbose crb cursorbind cuc cursorcolumn cul cursorline culopt cursorlineopt debug def define deco delcombine dict dictionary diff dia diffanchors dex diffexpr dip diffopt dg digraph dir directory dy display ead eadirection ed edcompatible emo emoji enc encoding eof endoffile eol endofline ea equalalways ep equalprg
+syn keyword vimOptionVarName contained eb errorbells ef errorfile efm errorformat ek esckeys ei eventignore eiw eventignorewin et expandtab ex exrc fenc fileencoding fencs fileencodings ff fileformat ffs fileformats fic fileignorecase ft filetype fcs fillchars ffu findfunc fixeol fixendofline fcl foldclose fdc foldcolumn fen foldenable fde foldexpr fdi foldignore fdl foldlevel fdls foldlevelstart fmr foldmarker fdm foldmethod fml foldminlines fdn foldnestmax fdo foldopen fdt foldtext fex formatexpr flp formatlistpat fo formatoptions fp formatprg fs fsync gd gdefault gfm grepformat gp grepprg gcr guicursor gfn guifont gfs guifontset gfw guifontwide ghr guiheadroom gli guiligatures go guioptions guipty gtl guitablabel gtt guitabtooltip hf helpfile hh helpheight
+syn keyword vimOptionVarName contained hlg helplang hid hidden hl highlight hi history hk hkmap hkp hkmapp hls hlsearch icon iconstring ic ignorecase imaf imactivatefunc imak imactivatekey imc imcmdline imd imdisable imi iminsert ims imsearch imsf imstatusfunc imst imstyle inc include inex includeexpr is incsearch inde indentexpr indk indentkeys inf infercase im insertmode ise isexpand isf isfname isi isident isk iskeyword isp isprint js joinspaces jop jumpoptions key kmp keymap km keymodel kpc keyprotocol kp keywordprg lmap langmap lm langmenu lnr langnoremap lrm langremap ls laststatus lz lazyredraw lhi lhistory lbr linebreak lines lsp linespace lisp lop lispoptions lw lispwords list lcs listchars lpl loadplugins luadll magic mef makeef menc makeencoding mp makeprg
+syn keyword vimOptionVarName contained mps matchpairs mat matchtime mco maxcombine mfd maxfuncdepth mmd maxmapdepth mm maxmem mmp maxmempattern mmt maxmemtot msc maxsearchcount mis menuitems mopt messagesopt msm mkspellmem ml modeline mle modelineexpr mls modelines ma modifiable mod modified more mouse mousef mousefocus mh mousehide mousem mousemodel mousemev mousemoveevent mouses mouseshape mouset mousetime mzq mzquantum mzschemedll mzschemegcdll nf nrformats nu number nuw numberwidth ofu omnifunc odev opendevice opfunc operatorfunc ost osctimeoutlen pp packpath para paragraphs paste pt pastetoggle pex patchexpr pm patchmode pa path perldll pi preserveindent pvh previewheight pvp previewpopup pvw previewwindow pdev printdevice penc printencoding pexpr printexpr
+syn keyword vimOptionVarName contained pfn printfont pheader printheader pmbcs printmbcharset pmbfn printmbfont popt printoptions prompt ph pumheight pmw pummaxwidth pw pumwidth pythondll pythonhome pythonthreedll pythonthreehome pyx pyxversion qftf quickfixtextfunc qe quoteescape ro readonly rdt redrawtime re regexpengine rnu relativenumber remap rop renderoptions report rs restorescreen ri revins rl rightleft rlc rightleftcmd rubydll ru ruler ruf rulerformat rtp runtimepath scr scroll scb scrollbind scf scrollfocus sj scrolljump so scrolloff sbo scrollopt sect sections secure sel selection slm selectmode ssop sessionoptions sh shell shcf shellcmdflag sp shellpipe shq shellquote srr shellredir ssl shellslash stmp shelltemp st shelltype sxe shellxescape sxq shellxquote
+syn keyword vimOptionVarName contained sr shiftround sw shiftwidth shm shortmess sn shortname sbr showbreak sc showcmd sloc showcmdloc sft showfulltag sm showmatch smd showmode stal showtabline stpl showtabpanel ss sidescroll siso sidescrolloff scl signcolumn scs smartcase si smartindent sta smarttab sms smoothscroll sts softtabstop spell spc spellcapcheck spf spellfile spl spelllang spo spelloptions sps spellsuggest sb splitbelow spk splitkeep spr splitright sol startofline stl statusline su suffixes sua suffixesadd swf swapfile sws swapsync swb switchbuf smc synmaxcol syn syntax tcl tabclose tal tabline tpm tabpagemax tpl tabpanel tplo tabpanelopt ts tabstop tbs tagbsearch tc tagcase tfu tagfunc tl taglength tr tagrelative tag tags tgst tagstack tcldll term
+syn keyword vimOptionVarName contained tbidi termbidi tenc termencoding tgc termguicolors twk termwinkey twsl termwinscroll tws termwinsize twt termwintype terse ta textauto tx textmode tw textwidth tsr thesaurus tsrfu thesaurusfunc top tildeop to timeout tm timeoutlen title titlelen titleold titlestring tb toolbar tbis toolbariconsize ttimeout ttm ttimeoutlen tbi ttybuiltin tf ttyfast ttym ttymouse tsl ttyscroll tty ttytype udir undodir udf undofile ul undolevels ur undoreload uc updatecount ut updatetime vsts varsofttabstop vts vartabstop vbs verbose vfile verbosefile vdir viewdir vop viewoptions vi viminfo vif viminfofile ve virtualedit vb visualbell warn wiv weirdinvert ww whichwrap wc wildchar wcm wildcharm wig wildignore wic wildignorecase wmnu wildmenu
+syn keyword vimOptionVarName contained wim wildmode wop wildoptions wak winaltkeys wcr wincolor wi window wfb winfixbuf wfh winfixheight wfw winfixwidth wh winheight wmh winminheight wmw winminwidth winptydll wiw winwidth wse wlseat wst wlsteal wtm wltimeoutlen wrap wm wrapmargin ws wrapscan write wa writeany wb writebackup wd writedelay xtermcodes
 " GEN_SYN_VIM: vimOption term output code variable, START_STR='syn keyword vimOptionVarName contained', END_STR=''
 syn keyword vimOptionVarName contained t_AB t_AF t_AU t_AL t_al t_bc t_BE t_BD t_cd t_ce t_Ce t_CF t_cl t_cm t_Co t_CS t_Cs t_cs t_CV t_da t_db t_DL t_dl t_ds t_Ds t_EC t_EI t_fs t_fd t_fe t_GP t_IE t_IS t_ke t_ks t_le t_mb t_md t_me t_mr t_ms t_nd t_op t_RF t_RB t_RC t_RI t_Ri t_RK t_RS t_RT t_RV t_Sb t_SC t_se t_Sf t_SH t_SI t_Si t_so t_SR t_sr t_ST t_Te t_te t_TE t_ti t_TI t_Ts t_ts t_u7 t_ue t_us t_Us t_ut t_vb t_ve t_vi t_VS t_vs t_WP t_WS t_XM t_xn t_xs t_ZH t_ZR t_8f t_8b t_8u t_xo
 syn keyword vimOptionVarName contained t_F1 t_F2 t_F3 t_F4 t_F5 t_F6 t_F7 t_F8 t_F9 t_k1 t_K1 t_k2 t_k3 t_K3 t_k4 t_K4 t_k5 t_K5 t_k6 t_K6 t_k7 t_K7 t_k8 t_K8 t_k9 t_K9 t_KA t_kb t_kB t_KB t_KC t_kd t_kD t_KD t_KE t_KF t_KG t_kh t_KH t_kI t_KI t_KJ t_KK t_kl t_KL t_kN t_kP t_kr t_ku
@@ -160,13 +159,13 @@ syn keyword vimFuncName contained histadd histdel histget histnr hlID hlexists h
 syn keyword vimFuncName contained mzeval nextnonblank ngettext nr2char or pathshorten perleval popup_atcursor popup_beval popup_clear popup_close popup_create popup_dialog popup_filter_menu popup_filter_yesno popup_findecho popup_findinfo popup_findpreview popup_getoptions popup_getpos popup_hide popup_list popup_locate popup_menu popup_move popup_notification popup_setbuf popup_setoptions popup_settext popup_show pow prevnonblank printf prompt_getprompt prompt_setcallback prompt_setinterrupt prompt_setprompt prop_add prop_add_list prop_clear prop_find prop_list prop_remove prop_type_add prop_type_change prop_type_delete prop_type_get prop_type_list pum_getpos pumvisible py3eval pyeval pyxeval rand range readblob readdir readdirex readfile reduce reg_executing
 syn keyword vimFuncName contained reg_recording reltime reltimefloat reltimestr remote_expr remote_foreground remote_peek remote_read remote_send remote_startserver remove rename repeat resolve reverse round rubyeval screenattr screenchar screenchars screencol screenpos screenrow screenstring search searchcount searchdecl searchpair searchpairpos searchpos server2client serverlist setbufline setbufvar setcellwidths setcharpos setcharsearch setcmdline setcmdpos setcursorcharpos setenv setfperm setline setloclist setmatches setpos setqflist setreg settabvar settabwinvar settagstack setwinvar sha256 shellescape shiftwidth sign_define sign_getdefined sign_getplaced sign_jump sign_place sign_placelist sign_undefine sign_unplace sign_unplacelist simplify sin sinh slice
 syn keyword vimFuncName contained sort sound_clear sound_playevent sound_playfile sound_stop soundfold spellbadword spellsuggest split sqrt srand state str2blob str2float str2list str2nr strcharlen strcharpart strchars strdisplaywidth strftime strgetchar stridx string strlen strpart strptime strridx strtrans strutf16len strwidth submatch substitute swapfilelist swapinfo swapname synID synIDattr synIDtrans synconcealed synstack system systemlist tabpagebuflist tabpagenr tabpagewinnr tagfiles taglist tan tanh tempname term_dumpdiff term_dumpload term_dumpwrite term_getaltscreen term_getansicolors term_getattr term_getcursor term_getjob term_getline term_getscrolled term_getsize term_getstatus term_gettitle term_gettty term_list term_scrape term_sendkeys term_setansicolors
-syn keyword vimFuncName contained term_setapi term_setkill term_setrestore term_setsize term_start term_wait terminalprops test_alloc_fail test_autochdir test_feedinput test_garbagecollect_now test_garbagecollect_soon test_getvalue test_gui_event test_ignore_error test_mswin_event test_null_blob test_null_channel test_null_dict test_null_function test_null_job test_null_list test_null_partial test_null_string test_null_tuple test_option_not_set test_override test_refcount test_setmouse test_settime test_srand_seed test_unknown test_void timer_info timer_pause timer_start timer_stop timer_stopall tolower toupper tr trim trunc tuple2list type typename undofile undotree uniq utf16idx values virtcol virtcol2col visualmode wildmenumode wildtrigger win_execute win_findbuf
-syn keyword vimFuncName contained win_getid win_gettype win_gotoid win_id2tabwin win_id2win win_move_separator win_move_statusline win_screenpos win_splitmove winbufnr wincol windowsversion winheight winlayout winline winnr winrestcmd winrestview winsaveview winwidth wordcount writefile xor
+syn keyword vimFuncName contained term_setapi term_setkill term_setrestore term_setsize term_start term_wait terminalprops test_alloc_fail test_autochdir test_feedinput test_garbagecollect_now test_garbagecollect_soon test_getvalue test_gui_event test_ignore_error test_mswin_event test_null_blob test_null_channel test_null_dict test_null_function test_null_job test_null_list test_null_partial test_null_string test_null_tuple test_option_not_set test_override test_refcount test_setmouse test_settime test_srand_seed test_unknown test_void timer_info timer_pause timer_start timer_stop timer_stopall tolower toupper tr trim trunc tuple2list type typename undofile undotree uniq uri_decode uri_encode utf16idx values virtcol virtcol2col visualmode wildmenumode wildtrigger
+syn keyword vimFuncName contained win_execute win_findbuf win_getid win_gettype win_gotoid win_id2tabwin win_id2win win_move_separator win_move_statusline win_screenpos win_splitmove winbufnr wincol windowsversion winheight winlayout winline winnr winrestcmd winrestview winsaveview winwidth wordcount writefile xor
 
 " Predefined variable names {{{2
 " GEN_SYN_VIM: vimVarName, START_STR='syn keyword vimVimVarName contained', END_STR=''
 syn keyword vimVimVarName contained count count1 prevcount errmsg warningmsg statusmsg shell_error this_session version lnum termresponse fname lang lc_time ctype charconvert_from charconvert_to fname_in fname_out fname_new fname_diff cmdarg foldstart foldend folddashes foldlevel progname servername dying exception throwpoint register cmdbang insertmode val key profiling fcs_reason fcs_choice beval_bufnr beval_winnr beval_winid beval_lnum beval_col beval_text scrollstart swapname swapchoice swapcommand char mouse_win mouse_winid mouse_lnum mouse_col operator searchforward hlsearch oldfiles windowid progpath completed_item option_new option_old option_oldlocal option_oldglobal option_command option_type errors false true none null numbermax numbermin numbersize
-syn keyword vimVimVarName contained vim_did_enter testing t_number t_string t_func t_list t_dict t_float t_bool t_none t_job t_channel t_blob t_class t_object termrfgresp termrbgresp termu7resp termstyleresp termblinkresp event versionlong echospace argv collate exiting colornames sizeofint sizeoflong sizeofpointer maxcol python3_version t_typealias t_enum t_enumvalue stacktrace t_tuple wayland_display clipmethod termda1
+syn keyword vimVimVarName contained vim_did_enter testing t_number t_string t_func t_list t_dict t_float t_bool t_none t_job t_channel t_blob t_class t_object termrfgresp termrbgresp termu7resp termstyleresp termblinkresp event versionlong echospace argv collate exiting colornames sizeofint sizeoflong sizeofpointer maxcol python3_version t_typealias t_enum t_enumvalue stacktrace t_tuple wayland_display clipmethod termda1 termosc
 
 "--- syntax here and above generated by runtime/syntax/generator/gen_syntax_vim.vim ---
 
index bc418ff9d36f031002dad2c7e16f30319d7f27c6..ebe8ed4312da2a719ca555073863ce8da1803c90 100644 (file)
@@ -3793,3 +3793,5 @@ EXTERN char e_socket_server_failed_connecting[]
 EXTERN char e_socket_server_unavailable[]
        INIT(= N_("E1567: Cannot start socket server, socket path is unavailable"));
 #endif
+EXTERN char e_osc_response_timed_out[]
+       INIT(= N_("E1568: OSC command response timed out: %.*s"));
index 78d8a1755f68e3e7c665f64510b0ddd825c605fd..c43841d348bff56cf3bd170f4beeb4d3b23cd25c 100644 (file)
@@ -141,8 +141,8 @@ static struct vimvar
     {VV_NAME("t_blob",          VAR_NUMBER), NULL, VV_RO},
     {VV_NAME("t_class",                 VAR_NUMBER), NULL, VV_RO},
     {VV_NAME("t_object",        VAR_NUMBER), NULL, VV_RO},
-    {VV_NAME("termrfgresp",     VAR_STRING), NULL, VV_RO},
-    {VV_NAME("termrbgresp",     VAR_STRING), NULL, VV_RO},
+    {VV_NAME("termrfgresp",     VAR_STRING), NULL, 0},
+    {VV_NAME("termrbgresp",     VAR_STRING), NULL, 0},
     {VV_NAME("termu7resp",      VAR_STRING), NULL, VV_RO},
     {VV_NAME("termstyleresp",   VAR_STRING), NULL, VV_RO},
     {VV_NAME("termblinkresp",   VAR_STRING), NULL, VV_RO},
@@ -166,6 +166,7 @@ static struct vimvar
     {VV_NAME("wayland_display",  VAR_STRING), NULL, VV_RO},
     {VV_NAME("clipmethod",      VAR_STRING), NULL, VV_RO},
     {VV_NAME("termda1",                 VAR_STRING), NULL, VV_RO},
+    {VV_NAME("termosc",         VAR_STRING), NULL, VV_RO},
 };
 
 // shorthand
@@ -2910,6 +2911,17 @@ set_vim_var_string(
        vimvars[idx].vv_str = vim_strnsave(val, len);
 }
 
+    void
+set_vim_var_string_direct(
+    int                idx,
+    char_u     *val)
+{
+    clear_tv(&vimvars[idx].vv_di.di_tv);
+    vimvars[idx].vv_tv_type = VAR_STRING;
+
+    vimvars[idx].vv_str = val;
+}
+
 /*
  * Set List v: variable to "val".
  */
index 0d1bd8a2816b272ccbcbd1ea00d43e6c3575c6f7..6b5909f1cef4187dfac58d13e6b18a00f539b29c 100644 (file)
@@ -82,7 +82,13 @@ static int   KeyNoremap = 0;     // remapping flags
 // typebuf.tb_buf has three parts: room in front (for result of mappings), the
 // middle for typeahead and room for new characters (which needs to be 3 *
 // MAXMAPLEN for the Amiga).
+#ifdef FEAT_NORMAL
+// Add extra space to handle large OSC responses in bigger chunks (improve
+// performance)
+#define TYPELEN_INIT   (5 * (MAXMAPLEN + 3) + 2048)
+#else // Tiny version
 #define TYPELEN_INIT   (5 * (MAXMAPLEN + 3))
+#endif
 static char_u  typebuf_init[TYPELEN_INIT];     // initial typebuf.tb_buf
 static char_u  noremapbuf_init[TYPELEN_INIT];  // initial typebuf.tb_noremap
 
index c77454a26fbb5cc2b5343c5face1ae85217dd390..942a7e5f8ffb58de66dac094324b76d300711f8a 100644 (file)
@@ -883,8 +883,6 @@ vim_main2(void)
     // Requesting the termresponse is postponed until here, so that a "-c q"
     // argument doesn't make it appear in the shell Vim was started from.
     may_req_termresponse();
-
-    may_req_bg_color();
 #endif
 
     // start in insert mode
index 2aa06027a4e0a5b96c8150f22c9eb0f42f270a90..f258836ec4aee98a9c4d35803290a9d2b78070e5 100644 (file)
@@ -3905,6 +3905,21 @@ did_set_numberwidth(optset_T *args UNUSED)
 }
 #endif
 
+/*
+ * Process the updated 'osctimeoutlen' option value.
+ */
+    char *
+did_set_osctimeoutlen(optset_T *args)
+{
+    if (p_ost < 0)
+    {
+       p_ost = args->os_oldval.number;
+       return e_argument_must_be_positive;
+    }
+
+    return NULL;
+}
+
 /*
  * Process the updated 'paste' option value.  Called after p_paste was set or
  * reset.  When 'paste' is set or reset also change other options.
index a17f61507b057436d3f0ffcea6134aa10bcd2f47..ce75d6862e64ecbd8d91b16c25fe061a069ad929 100644 (file)
@@ -828,6 +828,7 @@ EXTERN char_u       *p_nf;          // 'nrformats'
 #if defined(MSWIN)
 EXTERN int     p_odev;         // 'opendevice'
 #endif
+EXTERN long    p_ost;          // 'osctimeoutlen'
 EXTERN char_u  *p_opfunc;      // 'operatorfunc'
 EXTERN char_u  *p_para;        // 'paragraphs'
 EXTERN int     p_paste;        // 'paste'
index 77155a63e89da647642c7bc2786b278405ad0989..e667e4f2c3d10aa009e20203ef0b4baadb18930d 100644 (file)
@@ -1926,6 +1926,9 @@ static struct vimoption options[] =
     {"optimize",    "opt",  P_BOOL|P_VI_DEF,
                            (char_u *)NULL, PV_NONE, NULL, NULL,
                            {(char_u *)FALSE, (char_u *)0L} SCTX_INIT},
+    {"osctimeoutlen", "ost", P_NUM|P_VI_DEF,
+                           (char_u *)&p_ost, PV_NONE, did_set_osctimeoutlen, NULL,
+                           {(char_u *)1000, (char_u *)0L} SCTX_INIT},
     {"osfiletype",  "oft",  P_STRING|P_ALLOCED|P_VI_DEF,
                            (char_u *)NULL, PV_NONE, NULL, NULL,
                            {(char_u *)0L, (char_u *)0L} SCTX_INIT},
index bf4456772612f8871bbecef7ec03b1e4d64d9575..cb7214ad4a9d74172e6640f5627bed68b7845b3c 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: Vim\n"
 "Report-Msgid-Bugs-To: vim-dev@vim.org\n"
-"POT-Creation-Date: 2025-08-23 16:16+0200\n"
+"POT-Creation-Date: 2025-08-27 19:10+0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -8832,6 +8832,10 @@ msgstr ""
 msgid "E1567: Cannot start socket server, socket path is unavailable"
 msgstr ""
 
+#, c-format
+msgid "E1568: OSC command response timed out: %.*s"
+msgstr ""
+
 #. type of cmdline window or 0
 #. result of cmdline window or 0
 #. buffer of cmdline window or NULL
@@ -9691,6 +9695,9 @@ msgstr ""
 msgid "restore the screen contents when exiting Vim"
 msgstr ""
 
+msgid "timeout used for terminal OSC responses"
+msgstr ""
+
 msgid "using the mouse"
 msgstr ""
 
index a0e01000160cac32de3e28180c2a7a2b971d39fc..4c62286d3975f3d9b98f002581a811173916cb32 100644 (file)
@@ -51,6 +51,7 @@ void set_vcount(long count, long count1, int set_prevcount);
 void save_vimvars(vimvars_save_T *vvsave);
 void restore_vimvars(vimvars_save_T *vvsave);
 void set_vim_var_string(int idx, char_u *val, int len);
+void set_vim_var_string_direct(int idx, char_u *val);
 void set_vim_var_list(int idx, list_T *val);
 void set_vim_var_dict(int idx, dict_T *val);
 void set_argv_var(char **argv, int argc);
index f1f8a33a468e849aa121417a371350a4c2797976..cae025d31f76084d70fcf17c1c48d990e7b5331e 100644 (file)
@@ -58,6 +58,7 @@ char *did_set_modified(optset_T *args);
 char *did_set_mousehide(optset_T *args);
 char *did_set_number_relativenumber(optset_T *args);
 char *did_set_numberwidth(optset_T *args);
+char *did_set_osctimeoutlen(optset_T *args);
 char *did_set_paste(optset_T *args);
 char *did_set_previewwindow(optset_T *args);
 char *did_set_pyxversion(optset_T *args);
index c76acabbf381813f9fb7b880c0717d899ec9a990..8b48011b63e84efc1fb0acaacf3eb2ab7c989003 100644 (file)
@@ -59,7 +59,6 @@ void starttermcap(void);
 void stoptermcap(void);
 void may_req_termresponse(void);
 void check_terminal_behavior(void);
-void may_req_bg_color(void);
 int swapping_screen(void);
 void scroll_start(void);
 void cursor_on_force(void);
index 7e44bca1b7c8fcbbcc6382d2183bf24d57fa10c3..d9739b4188356098a94bcce129ebf4d2521f6e7e 100644 (file)
@@ -20,6 +20,9 @@ void f_timer_pause(typval_T *argvars, typval_T *rettv);
 void f_timer_start(typval_T *argvars, typval_T *rettv);
 void f_timer_stop(typval_T *argvars, typval_T *rettv);
 void f_timer_stopall(typval_T *argvars, typval_T *rettv);
+#if defined(MSWIN) || defined(__MINGW32__)
+int gettimeofday(struct timeval *tv, char *dummy);
+#endif
 void time_push(void *tv_rel, void *tv_start);
 void time_pop(void *tp);
 void time_msg(char *mesg, void *tv_start);
index 0968b3c9a9e6a15365fc42d07c9973859fbc3dbe..ed7f90a61e2333b6df19cb96726ff3b2703e3611 100644 (file)
@@ -1290,6 +1290,19 @@ typedef struct
 #endif
 } tasave_T;
 
+// Holds state for current OSC response.
+typedef struct
+{
+    int                    processing; // If we are in the middle of an OSC response
+    char_u         start_char; // First char in the OSC response
+    garray_T       buf;        // Buffer holding the OSC response, to be
+                               // placed in the "v:termosc" vim var.
+
+    struct timeval  start;     // Set at the beginning of an OSC response.
+                               // Used to timeout after a set amount of
+                               // time.
+} oscstate_T;
+
 /*
  * Used for conversion of terminal I/O and script files.
  */
index 684a9476b3eb711cf366b61f643f2325f65ed240..88061e075abf119610f570a97465dd46a9f3ee92 100644 (file)
@@ -116,19 +116,6 @@ static termrequest_T u7_status = TERMREQUEST_INIT;
 static termrequest_T xcc_status = TERMREQUEST_INIT;
 
 #ifdef FEAT_TERMRESPONSE
-# ifdef FEAT_TERMINAL
-// Request foreground color report:
-static termrequest_T rfg_status = TERMREQUEST_INIT;
-static int fg_r = 0;
-static int fg_g = 0;
-static int fg_b = 0;
-static int bg_r = 255;
-static int bg_g = 255;
-static int bg_b = 255;
-# endif
-
-// Request background color report:
-static termrequest_T rbg_status = TERMREQUEST_INIT;
 
 // Request cursor blinking mode report:
 static termrequest_T rbm_status = TERMREQUEST_INIT;
@@ -143,10 +130,6 @@ static termrequest_T *all_termrequests[] = {
     &crv_status,
     &u7_status,
     &xcc_status,
-# ifdef FEAT_TERMINAL
-    &rfg_status,
-# endif
-    &rbg_status,
     &rbm_status,
     &rcs_status,
     &winpos_status,
@@ -4192,49 +4175,6 @@ check_terminal_behavior(void)
     }
 }
 
-/*
- * Similar to requesting the version string: Request the terminal background
- * color when it is the right moment.
- */
-    void
-may_req_bg_color(void)
-{
-    if (can_get_termresponse() && starting == 0)
-    {
-       int didit = FALSE;
-
-# ifdef FEAT_TERMINAL
-       // Only request foreground if t_RF is set.
-       if (rfg_status.tr_progress == STATUS_GET && *T_RFG != NUL)
-       {
-           MAY_WANT_TO_LOG_THIS;
-           LOG_TR1("Sending FG request");
-           out_str(T_RFG);
-           termrequest_sent(&rfg_status);
-           didit = TRUE;
-       }
-# endif
-
-       // Only request background if t_RB is set.
-       if (rbg_status.tr_progress == STATUS_GET && *T_RBG != NUL)
-       {
-           MAY_WANT_TO_LOG_THIS;
-           LOG_TR1("Sending BG request");
-           out_str(T_RBG);
-           termrequest_sent(&rbg_status);
-           didit = TRUE;
-       }
-
-       if (didit)
-       {
-           // check for the characters now, otherwise they might be eaten by
-           // get_keystroke()
-           out_flush();
-           (void)vpeekc_nomap();
-       }
-    }
-}
-
 #endif
 
 /*
@@ -5740,105 +5680,89 @@ handle_csi(
     return 0;
 }
 
+static oscstate_T osc_state;
+
 /*
- * Handle an OSC sequence, fore/background color response from the terminal:
- *
- *       {lead}{code};rgb:{rrrr}/{gggg}/{bbbb}{tail}
- * or    {lead}{code};rgb:{rr}/{gg}/{bb}{tail}
- *
- * {code} is 10 for foreground, 11 for background
- * {lead} can be <Esc>] or OSC
- * {tail} can be '\007', <Esc>\ or STERM.
- *
- * Consume any code that starts with "{lead}11;", it's also
- * possible that "rgba" is following.
+ * Handles any OSC sequence and places the result in "v:termosc". Note that the
+ * OSC identifier and terminator character(s) will not be placed in the final
+ * result. Returns OK on success and FAIL on failure.
  */
     static int
-handle_osc(char_u *tp, char_u *argp, int len, char_u *key_name, int *slen)
+handle_osc(char_u *tp, int len, char_u *key_name, int *slen)
 {
-    int                i, j;
+    struct timeval  now;
+    char_u         last_char;
 
-    j = 1 + (tp[0] == ESC);
-    if (len >= j + 3 && (argp[0] != '1'
-                            || (argp[1] != '1' && argp[1] != '0')
-                            || argp[2] != ';'))
-       i = 0; // no match
+    if (!osc_state.processing)
+    {
+       int cur;
+
+       LOG_TRN("Received OSC response: %s", (char*)tp);
+       // Check if it is a valid OSC sequence, and consume it. OSC format
+       // consists of:
+       // <idenfitifer><data><terminator>
+       // <identifier> is either <Esc>] or an OSC character
+       // <terminator> can be '\007', <Esc>\ or STERM.
+       cur = 1 + (tp[0] == ESC);
+
+       if (len < cur + 1 + (tp[0] != OSC)) // Include terminator as well
+           return FAIL;
+
+       // The whole OSC response may be larger than the typeahead buffer.
+       // To handle this, keep reading data in and out of the typeahead
+       // buffer until we read an OSC terminator or timeout.
+       ga_init2(&osc_state.buf, 1, 1024);
+       gettimeofday(&osc_state.start, NULL);
+
+       osc_state.processing = TRUE;
+       osc_state.start_char = tp[0];
+       last_char = 0;
+    }
     else
-       for (i = j; i < len; ++i)
-           if (tp[i] == '\007' || (tp[0] == OSC ? tp[i] == STERM
-                       : (tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')))
-           {
-               int is_bg = argp[1] == '1';
-               int is_4digit = i - j >= 21 && tp[j + 11] == '/'
-                                                 && tp[j + 16] == '/';
-
-               if (i - j >= 15 && STRNCMP(tp + j + 3, "rgb:", 4) == 0
-                           && (is_4digit
-                                  || (tp[j + 9] == '/' && tp[j + 12] == '/')))
-               {
-                   char_u *tp_r = tp + j + 7;
-                   char_u *tp_g = tp + j + (is_4digit ? 12 : 10);
-                   char_u *tp_b = tp + j + (is_4digit ? 17 : 13);
-#if defined(FEAT_TERMRESPONSE) && defined(FEAT_TERMINAL)
-                   int rval, gval, bval;
+       last_char = ((char_u *)osc_state.buf.ga_data)[osc_state.buf.ga_len - 1];
+
+    key_name[0] = (int)KS_EXTRA;
+    key_name[1] = (int)KE_IGNORE;
+
+    // Read data and append to buffer. If we reach a terminator, then
+    // finally set the vim var.
+    for (int i = 0; i < len; i++)
+       if (tp[i] == '\007' || (osc_state.start_char == OSC ? tp[i] == STERM
+                   : ((tp[i] == ESC && i + 1 < len && tp[i + 1] == '\\')
+                       || (i == 0 && tp[i] == '\\' && last_char == ESC)
+                       )))
+       {
+           osc_state.processing = FALSE;
 
-                   rval = hexhex2nr(tp_r);
-                   gval = hexhex2nr(tp_g);
-                   bval = hexhex2nr(tp_b);
+           ga_concat_len(&osc_state.buf, tp, i + 1 + (tp[i] == ESC));
+           ga_append(&osc_state.buf, NUL);
+           *slen = i + 1 + (tp[i] == ESC);
+#ifdef FEAT_EVAL
+           set_vim_var_string_direct(VV_TERMOSC, osc_state.buf.ga_data);
 #endif
-                   if (is_bg)
-                   {
-                       char *new_bg_val = (3 * '6' < *tp_r + *tp_g +
-                                            *tp_b) ? "light" : "dark";
+           apply_autocmds(EVENT_TERMRESPONSEALL, (char_u *)"osc",
+                   NULL, FALSE, curbuf);
+           return OK;
+       }
 
-                       LOG_TRN("Received RBG response: %s", tp);
-#ifdef FEAT_TERMRESPONSE
-                       rbg_status.tr_progress = STATUS_GOT;
-# ifdef FEAT_TERMINAL
-                       bg_r = rval;
-                       bg_g = gval;
-                       bg_b = bval;
-# endif
-#endif
-                       if (!option_was_set((char_u *)"bg")
-                                     && STRCMP(p_bg, new_bg_val) != 0)
-                       {
-                           // value differs, apply it
-                           set_option_value_give_err((char_u *)"bg",
-                                                 0L, (char_u *)new_bg_val, 0);
-                           reset_option_was_set((char_u *)"bg");
-                           redraw_asap(UPD_CLEAR);
-                       }
-                   }
-#if defined(FEAT_TERMRESPONSE) && defined(FEAT_TERMINAL)
-                   else
-                   {
-                       LOG_TRN("Received RFG response: %s", tp);
-                       rfg_status.tr_progress = STATUS_GOT;
-                       fg_r = rval;
-                       fg_g = gval;
-                       fg_b = bval;
-                   }
-#endif
-               }
+    // Check if timeout has been reached
+    gettimeofday(&now, NULL);
 
-               // got finished code: consume it
-               key_name[0] = (int)KS_EXTRA;
-               key_name[1] = (int)KE_IGNORE;
-               *slen = i + 1 + (tp[i] == ESC);
-#ifdef FEAT_EVAL
-               set_vim_var_string(is_bg ? VV_TERMRBGRESP
-                                                 : VV_TERMRFGRESP, tp, *slen);
-#endif
-               apply_autocmds(EVENT_TERMRESPONSEALL,
-                           is_bg ? (char_u *)"background" : (char_u *)"foreground", NULL, FALSE, curbuf);
-               break;
-           }
-    if (i == len)
+    if ((now.tv_sec * 1000000 + now.tv_usec) -
+           (osc_state.start.tv_sec * 1000000 + osc_state.start.tv_usec)
+           >= p_ost * 1000)
     {
-       LOG_TR1("not enough characters for RB");
+       semsg(_(e_osc_response_timed_out), osc_state.buf.ga_len,
+               osc_state.buf.ga_data);
+
+       ga_clear(&osc_state.buf);
+       osc_state.processing = FALSE;
        return FAIL;
     }
+
+    ga_concat(&osc_state.buf, tp);
+    *slen = len; // Consume everything
+
     return OK;
 }
 
@@ -6028,6 +5952,11 @@ check_termcode(
            continue;
        }
 
+       if (osc_state.processing)
+           // Still processing OSC response data, go straight to handler
+           // function.
+           goto handle_osc;
+
        /*
         * Skip this position if the character does not appear as the first
         * character in term_strings. This speeds up a lot, since most
@@ -6300,13 +6229,11 @@ check_termcode(
                }
            }
 
-           // Check for fore/background color response from the terminal,
-           // starting} with <Esc>] or OSC
-           else if ((*T_RBG != NUL || *T_RFG != NUL)
-                       && ((tp[0] == ESC && len >= 2 && tp[1] == ']')
-                           || tp[0] == OSC))
+           // Check for OSC responses from terminal
+           else if ((tp[0] == ESC && len >= 2 && tp[1] == ']') || tp[0] == OSC)
            {
-               if (handle_osc(tp, argp, len, key_name, &slen) == FAIL)
+handle_osc:
+               if (handle_osc(tp, len, key_name, &slen) == FAIL)
                    return -1;
            }
 
@@ -6549,10 +6476,12 @@ check_termcode(
         */
        key = handle_x_keys(TERMCAP2KEY(key_name[0], key_name[1]));
 
-       /*
-        * Add any modifier codes to our string.
-        */
-       new_slen = modifiers2keycode(modifiers, &key, string);
+       if (osc_state.processing)
+           // We don't want to add anything to the typeahead buffer.
+           new_slen = 0;
+       else
+           // Add any modifier codes to our string.
+           new_slen = modifiers2keycode(modifiers, &key, string);
 
        // Finally, add the special key code to our string
        key_name[0] = KEY2TERMCAP0(key);
@@ -6592,18 +6521,28 @@ check_termcode(
 }
 
 #if (defined(FEAT_TERMINAL) && defined(FEAT_TERMRESPONSE)) || defined(PROTO)
+
+    static void
+term_get_color(char_u *str, char_u *r, char_u *g, char_u *b)
+{
+    char_u rn[3], gn[3], bn[3];
+
+    if (sscanf((char *)str, "%*[^:]:%2s%*[^/]/%2s%*[^/]/%2s",
+               (char *)&rn, (char *)&gn, (char *)&bn) != 3)
+       return;
+
+    *r = hexhex2nr(rn);
+    *g = hexhex2nr(gn);
+    *b = hexhex2nr(bn);
+}
+
 /*
  * Get the text foreground color, if known.
  */
     void
 term_get_fg_color(char_u *r, char_u *g, char_u *b)
 {
-    if (rfg_status.tr_progress != STATUS_GOT)
-       return;
-
-    *r = fg_r;
-    *g = fg_g;
-    *b = fg_b;
+    term_get_color(get_vim_var_str(VV_TERMRFGRESP), r, g, b);
 }
 
 /*
@@ -6612,12 +6551,7 @@ 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)
 {
-    if (rbg_status.tr_progress != STATUS_GOT)
-       return;
-
-    *r = bg_r;
-    *g = bg_g;
-    *b = bg_b;
+    term_get_color(get_vim_var_str(VV_TERMRBGRESP), r, g, b);
 }
 #endif
 
index 0d4aeb0432fb506008c5f9366e9ed5b1d275683c..e02c63d52853aa58592e8b0786036d3d3e6c466c 100644 (file)
@@ -252,6 +252,7 @@ NEW_TESTS = \
        test_plugin_tohtml \
        test_plugin_tutor \
        test_plugin_zip \
+       test_plugin_colorresp \
        test_plus_arg_edit \
        test_popup \
        test_popupwin \
@@ -525,6 +526,7 @@ NEW_TESTS_RES = \
        test_plugin_tohtml.res \
        test_plugin_tutor.res \
        test_plugin_zip.res \
+       test_plugin_colorresp.res \
        test_plus_arg_edit.res \
        test_popup.res \
        test_popupwin.res \
diff --git a/src/testdir/test_plugin_colorresp.vim b/src/testdir/test_plugin_colorresp.vim
new file mode 100644 (file)
index 0000000..0300ff4
--- /dev/null
@@ -0,0 +1,74 @@
+" Test for the colorresp plugin
+
+CheckNotGui
+CheckUnix
+
+runtime plugin/colorresp.vim
+
+func Test_colorresp()
+    set t_RF=x
+    set t_RB=y
+
+    " response to t_RF, 4 digits
+    let red = 0x12
+    let green = 0x34
+    let blue = 0x56
+    let seq = printf("\<Esc>]10;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
+    call feedkeys(seq, 'Lx!')
+    call assert_equal(seq, v:termrfgresp)
+    " call WaitForAssert({-> assert_equal(seq, v:termrfgresp)})
+
+    " response to t_RF, 2 digits
+    let red = 0x78
+    let green = 0x9a
+    let blue = 0xbc
+    let seq = printf("\<Esc>]10;rgb:%02x/%02x/%02x\x07", red, green, blue)
+    call feedkeys(seq, 'Lx!')
+    call assert_equal(seq, v:termrfgresp)
+
+    " response to t_RB, 4 digits, dark
+    set background=light
+    call test_option_not_set('background')
+    let red = 0x29
+    let green = 0x4a
+    let blue = 0x6b
+    let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
+    call feedkeys(seq, 'Lx!')
+    call assert_equal(seq, v:termrbgresp)
+    call assert_equal('dark', &background)
+
+    " response to t_RB, 4 digits, light
+    set background=dark
+    call test_option_not_set('background')
+    let red = 0x81
+    let green = 0x63
+    let blue = 0x65
+    let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
+    call feedkeys(seq, 'Lx!')
+    call assert_equal(seq, v:termrbgresp)
+    call assert_equal('light', &background)
+
+    " response to t_RB, 2 digits, dark
+    set background=light
+    call test_option_not_set('background')
+    let red = 0x47
+    let green = 0x59
+    let blue = 0x5b
+    let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
+    call feedkeys(seq, 'Lx!')
+    call assert_equal(seq, v:termrbgresp)
+    call assert_equal('dark', &background)
+
+    " response to t_RB, 2 digits, light
+    set background=dark
+    call test_option_not_set('background')
+    let red = 0x83
+    let green = 0xa4
+    let blue = 0xc2
+    let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
+    call feedkeys(seq, 'Lx!')
+    call assert_equal(seq, v:termrbgresp)
+    call assert_equal('light', &background)
+
+    set t_RF= t_RB=
+  endfunc
index 52a34df6f4f533412287db0514f83500760ac7c3..99710fada53f283612a5f95c7c2fe9d2c780702d 100644 (file)
@@ -1632,74 +1632,6 @@ func Test_mouse_termcodes()
   %bw!
 endfunc
 
-" This only checks if the sequence is recognized.
-func Test_term_rgb_response()
-  set t_RF=x
-  set t_RB=y
-
-  " response to t_RF, 4 digits
-  let red = 0x12
-  let green = 0x34
-  let blue = 0x56
-  let seq = printf("\<Esc>]10;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
-  call feedkeys(seq, 'Lx!')
-  call assert_equal(seq, v:termrfgresp)
-
-  " response to t_RF, 2 digits
-  let red = 0x78
-  let green = 0x9a
-  let blue = 0xbc
-  let seq = printf("\<Esc>]10;rgb:%02x/%02x/%02x\x07", red, green, blue)
-  call feedkeys(seq, 'Lx!')
-  call assert_equal(seq, v:termrfgresp)
-
-  " response to t_RB, 4 digits, dark
-  set background=light
-  eval 'background'->test_option_not_set()
-  let red = 0x29
-  let green = 0x4a
-  let blue = 0x6b
-  let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
-  call feedkeys(seq, 'Lx!')
-  call assert_equal(seq, v:termrbgresp)
-  call assert_equal('dark', &background)
-
-  " response to t_RB, 4 digits, light
-  set background=dark
-  call test_option_not_set('background')
-  let red = 0x81
-  let green = 0x63
-  let blue = 0x65
-  let seq = printf("\<Esc>]11;rgb:%02x00/%02x00/%02x00\x07", red, green, blue)
-  call feedkeys(seq, 'Lx!')
-  call assert_equal(seq, v:termrbgresp)
-  call assert_equal('light', &background)
-
-  " response to t_RB, 2 digits, dark
-  set background=light
-  call test_option_not_set('background')
-  let red = 0x47
-  let green = 0x59
-  let blue = 0x5b
-  let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
-  call feedkeys(seq, 'Lx!')
-  call assert_equal(seq, v:termrbgresp)
-  call assert_equal('dark', &background)
-
-  " response to t_RB, 2 digits, light
-  set background=dark
-  call test_option_not_set('background')
-  let red = 0x83
-  let green = 0xa4
-  let blue = 0xc2
-  let seq = printf("\<Esc>]11;rgb:%02x/%02x/%02x\x07", red, green, blue)
-  call feedkeys(seq, 'Lx!')
-  call assert_equal(seq, v:termrbgresp)
-  call assert_equal('light', &background)
-
-  set t_RF= t_RB=
-endfunc
-
 " This only checks if the sequence is recognized.
 " This must be after other tests, because it has side effects to xterm
 " properties.
@@ -2808,4 +2740,17 @@ func Test_da1_handling()
   call assert_equal("\<Esc>[?62,52;c", v:termda1)
 endfunc
 
+" Test if OSC terminal responses are captured correctly
+func Test_term_response_osc()
+  " Test if large OSC responses (that must be processed in chunks) are handled
+  let data = repeat('a', 3000)
+
+  call feedkeys("\<Esc>]12;" .. data .. "\x07", 'Lx!')
+  call assert_equal("\<Esc>]12;" .. data .. "\x07", v:termosc)
+
+  " Test small OSC responses
+  call feedkeys("\<Esc>]15;hello world!\07", 'Lx!')
+  call assert_equal("\<Esc>]15;hello world!\x07", v:termosc)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 22bc352033c9ad35d7bac7152c2ed5fe931cdbd2..56ce92171f9f1f588c92bc499ee773278e6856ce 100644 (file)
@@ -116,6 +116,7 @@ let test_values = {
       \ 'winminwidth': [[0, 1, 10], [-1]],
       \ 'winwidth': [[1, 10, 999], [-1, 0]],
       \ 'wltimeoutlen': [[1, 10, 999],[-1]],
+      \ 'osctimeoutlen': [[0, 1, 8, 9999], [-1]],
       \
       "\ string options
       \ 'ambiwidth': [['', 'single', 'double'], ['xxx']],
index 2fb0c39317b83410dd9d4f6f792c2edf1e1d51c4..d451799485cc805c46df256d33b7dcfe7aa3e2b4 100644 (file)
@@ -127,6 +127,20 @@ get_ctime(time_t thetime, int add_newline)
     return buf;
 }
 
+#if defined(MSWIN) || defined(__MINGW32__)
+/*
+ * Windows doesn't have gettimeofday(), although it does have struct timeval.
+ */
+    int
+gettimeofday(struct timeval *tv, char *dummy UNUSED)
+{
+    long t = clock();
+    tv->tv_sec = t / CLOCKS_PER_SEC;
+    tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
+    return 0;
+}
+#endif
+
 #if defined(FEAT_EVAL) || defined(PROTO)
 
 #if defined(MACOS_X)
@@ -947,20 +961,6 @@ f_timer_stopall(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
 # if defined(STARTUPTIME) || defined(PROTO)
 static struct timeval  prev_timeval;
 
-#  ifdef MSWIN
-/*
- * Windows doesn't have gettimeofday(), although it does have struct timeval.
- */
-    static int
-gettimeofday(struct timeval *tv, char *dummy UNUSED)
-{
-    long t = clock();
-    tv->tv_sec = t / CLOCKS_PER_SEC;
-    tv->tv_usec = (t - tv->tv_sec * CLOCKS_PER_SEC) * 1000000 / CLOCKS_PER_SEC;
-    return 0;
-}
-#  endif
-
 /*
  * Save the previous time before doing something that could nest.
  * set "*tv_rel" to the time elapsed so far.
index 443f85bb89b184ee627b8132f851c4c3f2e65fcd..e1e0b950fbc995d811d20bb389bacece2071ad75 100644 (file)
@@ -724,6 +724,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1703,
 /**/
     1702,
 /**/
index 9845cbe78e3f06405f2df42f2f9308ba4365aefb..802ac73047d357baedc18b372718f16f27745b5f 100644 (file)
--- a/src/vim.h
+++ b/src/vim.h
@@ -2240,7 +2240,8 @@ typedef int sock_T;
 #define VV_WAYLAND_DISPLAY 112
 #define VV_CLIPMETHOD 113
 #define VV_TERMDA1 114
-#define VV_LEN         115     // number of v: vars
+#define VV_TERMOSC 115
+#define VV_LEN         116     // number of v: vars
 
 // used for v_number in VAR_BOOL and VAR_SPECIAL
 #define VVAL_FALSE     0L      // VAR_BOOL