aboutsummaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/doc/autocmd.txt24
-rw-r--r--runtime/doc/news.txt5
-rw-r--r--runtime/doc/terminal.txt4
-rw-r--r--runtime/lua/tohtml.lua4
-rw-r--r--runtime/lua/vim/_defaults.lua8
-rw-r--r--runtime/lua/vim/termcap.lua2
-rw-r--r--runtime/lua/vim/ui/clipboard/osc52.lua2
7 files changed, 33 insertions, 16 deletions
diff --git a/runtime/doc/autocmd.txt b/runtime/doc/autocmd.txt
index 413802eea1..0e582ce0e7 100644
--- a/runtime/doc/autocmd.txt
+++ b/runtime/doc/autocmd.txt
@@ -1004,22 +1004,32 @@ TermClose When a |terminal| job ends.
status
*TermRequest*
TermRequest When a |:terminal| child process emits an OSC,
- DCS or APC sequence. Sets |v:termrequest|. The
- |event-data| is the request string.
+ DCS, or APC sequence. Sets |v:termrequest|. The
+ |event-data| is a table with the following
+ fields:
+
+ - sequence: the received sequence
+ - cursor: (1,0)-indexed, buffer-relative
+ position of the cursor when the sequence was
+ received
+
*TermResponse*
TermResponse When Nvim receives an OSC or DCS response from
the host terminal. Sets |v:termresponse|. The
- |event-data| is the response string. May be
- triggered during another event (file I/O,
- a shell command, or anything else that takes
- time). Example: >lua
+ |event-data| is a table with the following fields:
+
+ - sequence: the received sequence
+
+ May be triggered during another event (file
+ I/O, a shell command, or anything else that
+ takes time). Example: >lua
-- Query the terminal palette for the RGB value of color 1
-- (red) using OSC 4
vim.api.nvim_create_autocmd('TermResponse', {
once = true,
callback = function(args)
- local resp = args.data
+ local resp = args.data.sequence
local r, g, b = resp:match("\027%]4;1;rgb:(%w+)/(%w+)/(%w+)")
end,
})
diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt
index 415a234254..4667af906f 100644
--- a/runtime/doc/news.txt
+++ b/runtime/doc/news.txt
@@ -111,6 +111,9 @@ EVENTS
• `history` argument indicating if the message was added to the history.
• new message kinds: "bufwrite", "completion", "list_cmd", "lua_print",
"search_cmd", "shell_out/err/ret", "undo", "verbose", wildlist".
+• |TermRequest| and |TermResponse| |event-data| is now a table. The "sequence"
+ field contains the received sequence. |TermRequest| also contains a "cursor"
+ field indicating the cursor's position when the sequence was received.
HIGHLIGHTS
@@ -396,6 +399,8 @@ TERMINAL
codes" mode is currently supported.
• The |terminal| emits a |TermRequest| autocommand event when the child process
emits an APC control sequence.
+• |TermRequest| has a "cursor" field in its |event-data| indicating the
+ cursor position when the sequence was received.
TREESITTER
diff --git a/runtime/doc/terminal.txt b/runtime/doc/terminal.txt
index 0ab7151728..4183bb8dcf 100644
--- a/runtime/doc/terminal.txt
+++ b/runtime/doc/terminal.txt
@@ -144,8 +144,8 @@ directory indicated in the request. >lua
vim.api.nvim_create_autocmd({ 'TermRequest' }, {
desc = 'Handles OSC 7 dir change requests',
callback = function(ev)
- if string.sub(vim.v.termrequest, 1, 4) == '\x1b]7;' then
- local dir = string.gsub(vim.v.termrequest, '\x1b]7;file://[^/]*', '')
+ if string.sub(ev.data.sequence, 1, 4) == '\x1b]7;' then
+ local dir = string.gsub(ev.data.sequence, '\x1b]7;file://[^/]*', '')
if vim.fn.isdirectory(dir) == 0 then
vim.notify('invalid dir: '..dir)
return
diff --git a/runtime/lua/tohtml.lua b/runtime/lua/tohtml.lua
index 4415a8cdca..6b8daab2c5 100644
--- a/runtime/lua/tohtml.lua
+++ b/runtime/lua/tohtml.lua
@@ -205,7 +205,9 @@ local function try_query_terminal_color(color)
once = true,
callback = function(args)
hex = '#'
- .. table.concat({ args.data:match('\027%]%d+;%d*;?rgb:(%w%w)%w%w/(%w%w)%w%w/(%w%w)%w%w') })
+ .. table.concat({
+ args.data.sequence:match('\027%]%d+;%d*;?rgb:(%w%w)%w%w/(%w%w)%w%w/(%w%w)%w%w'),
+ })
end,
})
if type(color) == 'number' then
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua
index c2e4e76dd6..544b0acbcc 100644
--- a/runtime/lua/vim/_defaults.lua
+++ b/runtime/lua/vim/_defaults.lua
@@ -515,8 +515,8 @@ do
if channel == 0 then
return
end
- local fg_request = args.data == '\027]10;?'
- local bg_request = args.data == '\027]11;?'
+ local fg_request = args.data.sequence == '\027]10;?'
+ local bg_request = args.data.sequence == '\027]11;?'
if fg_request or bg_request then
-- WARN: This does not return the actual foreground/background color,
-- but rather returns:
@@ -712,7 +712,7 @@ do
nested = true,
desc = "Update the value of 'background' automatically based on the terminal emulator's background color",
callback = function(args)
- local resp = args.data ---@type string
+ local resp = args.data.sequence ---@type string
local r, g, b = parseosc11(resp)
if r and g and b then
local rr = parsecolor(r)
@@ -788,7 +788,7 @@ do
group = group,
nested = true,
callback = function(args)
- local resp = args.data ---@type string
+ local resp = args.data.sequence ---@type string
local decrqss = resp:match('^\027P1%$r([%d;:]+)m$')
if decrqss then
diff --git a/runtime/lua/vim/termcap.lua b/runtime/lua/vim/termcap.lua
index 4aa41bba9b..23666a337a 100644
--- a/runtime/lua/vim/termcap.lua
+++ b/runtime/lua/vim/termcap.lua
@@ -34,7 +34,7 @@ function M.query(caps, cb)
local id = vim.api.nvim_create_autocmd('TermResponse', {
nested = true,
callback = function(args)
- local resp = args.data ---@type string
+ local resp = args.data.sequence ---@type string
local k, rest = resp:match('^\027P1%+r(%x+)(.*)$')
if k and rest then
local cap = vim.text.hexdecode(k)
diff --git a/runtime/lua/vim/ui/clipboard/osc52.lua b/runtime/lua/vim/ui/clipboard/osc52.lua
index 50afbe63a5..73f64c9743 100644
--- a/runtime/lua/vim/ui/clipboard/osc52.lua
+++ b/runtime/lua/vim/ui/clipboard/osc52.lua
@@ -25,7 +25,7 @@ function M.paste(reg)
local contents = nil
local id = vim.api.nvim_create_autocmd('TermResponse', {
callback = function(args)
- local resp = args.data ---@type string
+ local resp = args.data.sequence ---@type string
local encoded = resp:match('\027%]52;%w?;([A-Za-z0-9+/=]*)')
if encoded then
contents = vim.base64.decode(encoded)