mirror of
https://github.com/neovim/neovim.git
synced 2026-05-03 04:25:03 +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:
@@ -48,6 +48,7 @@
|
||||
local t = require('test.testutil')
|
||||
local n = require('test.functional.testnvim')()
|
||||
local busted = require('busted')
|
||||
local uv = vim.uv
|
||||
|
||||
local deepcopy = vim.deepcopy
|
||||
local shallowcopy = t.shallowcopy
|
||||
@@ -89,6 +90,7 @@ end
|
||||
--- @field private _grid_win_extmarks table<integer,table>
|
||||
--- @field private _attr_table table<integer,table>
|
||||
--- @field private _hl_info table<integer,table>
|
||||
--- @field private _stdout uv.uv_pipe_t?
|
||||
local Screen = {}
|
||||
Screen.__index = Screen
|
||||
|
||||
@@ -235,6 +237,7 @@ function Screen.new(width, height, options, session)
|
||||
col = 1,
|
||||
},
|
||||
_busy = false,
|
||||
_stdout = nil,
|
||||
}, Screen)
|
||||
|
||||
local function ui(method, ...)
|
||||
@@ -278,6 +281,12 @@ function Screen:set_rgb_cterm(val)
|
||||
self._rgb_cterm = val
|
||||
end
|
||||
|
||||
--- @param fd number
|
||||
function Screen:set_stdout(fd)
|
||||
self._stdout = assert(uv.new_pipe())
|
||||
self._stdout:open(fd)
|
||||
end
|
||||
|
||||
--- @param session? test.Session
|
||||
function Screen:attach(session)
|
||||
session = session or get_session()
|
||||
@@ -1416,6 +1425,12 @@ function Screen:_handle_msg_history_show(entries, prev_cmd)
|
||||
self.msg_history = { entries, prev_cmd }
|
||||
end
|
||||
|
||||
function Screen:_handle_ui_send(content)
|
||||
if self._stdout then
|
||||
self._stdout:write(content)
|
||||
end
|
||||
end
|
||||
|
||||
function Screen:_clear_block(grid, top, bot, left, right)
|
||||
for i = top, bot do
|
||||
self:_clear_row_section(grid, i, left, right)
|
||||
|
||||
Reference in New Issue
Block a user