mirror of
https://github.com/neovim/neovim.git
synced 2026-04-28 18:24:13 +00:00
feat(tui): add nvim_ui_send (#35406)
This function allows the Nvim core to write arbitrary data to a TTY connected to a UI's stdout.
This commit is contained in:
@@ -839,7 +839,7 @@ do
|
||||
end,
|
||||
})
|
||||
|
||||
io.stdout:write('\027]11;?\007')
|
||||
vim.api.nvim_ui_send('\027]11;?\007')
|
||||
end
|
||||
|
||||
--- If the TUI (term_has_truecolor) was able to determine that the host
|
||||
@@ -927,7 +927,7 @@ do
|
||||
local decrqss = '\027P$qm\027\\'
|
||||
|
||||
-- Reset attributes first, as other code may have set attributes.
|
||||
io.stdout:write(string.format('\027[0m\027[48;2;%d;%d;%dm%s', r, g, b, decrqss))
|
||||
vim.api.nvim_ui_send(string.format('\027[0m\027[48;2;%d;%d;%dm%s', r, g, b, decrqss))
|
||||
|
||||
timer:start(1000, 0, function()
|
||||
-- Delete the autocommand if no response was received
|
||||
|
||||
8
runtime/lua/vim/_meta/api.lua
generated
8
runtime/lua/vim/_meta/api.lua
generated
@@ -2340,6 +2340,14 @@ function vim.api.nvim_tabpage_set_var(tabpage, name, value) end
|
||||
--- @param win integer `window-ID`, must already belong to {tabpage}
|
||||
function vim.api.nvim_tabpage_set_win(tabpage, win) end
|
||||
|
||||
--- Sends arbitrary data to a UI.
|
||||
---
|
||||
--- This sends a "ui_send" event to any UI that has the "stdout_tty" `ui-option` set. UIs are
|
||||
--- expected to write the received data to a connected TTY if one exists.
|
||||
---
|
||||
--- @param content string Content to write to the TTY
|
||||
function vim.api.nvim_ui_send(content) end
|
||||
|
||||
--- Calls a function with window as temporary current window.
|
||||
---
|
||||
---
|
||||
|
||||
@@ -71,7 +71,7 @@ function M.query(caps, cb)
|
||||
|
||||
local query = string.format('\027P+q%s\027\\', table.concat(encoded, ';'))
|
||||
|
||||
io.stdout:write(query)
|
||||
vim.api.nvim_ui_send(query)
|
||||
|
||||
timer:start(1000, 0, function()
|
||||
-- Delete the autocommand if no response was received
|
||||
|
||||
@@ -14,8 +14,7 @@ function M.copy(reg)
|
||||
return function(lines)
|
||||
local s = table.concat(lines, '\n')
|
||||
-- The data to be written here can be quite long.
|
||||
-- Use nvim_chan_send() as io.stdout:write() doesn't handle EAGAIN. #26688
|
||||
vim.api.nvim_chan_send(2, osc52(clipboard, vim.base64.encode(s)))
|
||||
vim.api.nvim_ui_send(osc52(clipboard, vim.base64.encode(s)))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,7 +33,7 @@ function M.paste(reg)
|
||||
end,
|
||||
})
|
||||
|
||||
io.stdout:write(osc52(clipboard, '?'))
|
||||
vim.api.nvim_ui_send(osc52(clipboard, '?'))
|
||||
|
||||
local ok, res
|
||||
|
||||
|
||||
Reference in New Issue
Block a user