patch 9.1.1703: Cannot react to terminal OSC responses

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>
This commit is contained in:
Foxe Chen
2025-08-27 21:15:47 +02:00
committed by Christian Brabandt
parent 7f380259cf
commit 1f51bbc3b9
30 changed files with 404 additions and 303 deletions

View 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

View 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

View 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

View 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*

View 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