mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
commit
3c53371b0c
@ -250,11 +250,6 @@ static void tui_scheduler(Event event, void *d)
|
|||||||
loop_schedule(data->loop, event);
|
loop_schedule(data->loop, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void refresh_event(void **argv)
|
|
||||||
{
|
|
||||||
ui_refresh();
|
|
||||||
}
|
|
||||||
|
|
||||||
static void sigcont_cb(SignalWatcher *watcher, int signum, void *data)
|
static void sigcont_cb(SignalWatcher *watcher, int signum, void *data)
|
||||||
{
|
{
|
||||||
((TUIData *)data)->cont_received = true;
|
((TUIData *)data)->cont_received = true;
|
||||||
@ -265,8 +260,7 @@ static void sigwinch_cb(SignalWatcher *watcher, int signum, void *data)
|
|||||||
got_winch = true;
|
got_winch = true;
|
||||||
UI *ui = data;
|
UI *ui = data;
|
||||||
update_size(ui);
|
update_size(ui);
|
||||||
// run refresh_event in nvim main loop
|
ui_schedule_refresh();
|
||||||
loop_schedule(&main_loop, event_create(1, refresh_event, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool attrs_differ(HlAttrs a1, HlAttrs a2)
|
static bool attrs_differ(HlAttrs a1, HlAttrs a2)
|
||||||
|
@ -53,12 +53,10 @@ static bool pending_cursor_update = false;
|
|||||||
static int busy = 0;
|
static int busy = 0;
|
||||||
static int height, width;
|
static int height, width;
|
||||||
|
|
||||||
// This set of macros allow us to use UI_CALL to invoke any function on
|
// UI_CALL invokes a function on all registered UI instances. The functions can
|
||||||
// registered UI instances. The functions can have 0-5 arguments(configurable
|
// have 0-5 arguments (configurable by SELECT_NTH).
|
||||||
// by SELECT_NTH)
|
|
||||||
//
|
//
|
||||||
// See http://stackoverflow.com/a/11172679 for a better explanation of how it
|
// See http://stackoverflow.com/a/11172679 for how it works.
|
||||||
// works.
|
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
# define UI_CALL(funname, ...) \
|
# define UI_CALL(funname, ...) \
|
||||||
do { \
|
do { \
|
||||||
@ -169,8 +167,8 @@ void ui_refresh(void)
|
|||||||
|
|
||||||
for (size_t i = 0; i < ui_count; i++) {
|
for (size_t i = 0; i < ui_count; i++) {
|
||||||
UI *ui = uis[i];
|
UI *ui = uis[i];
|
||||||
width = ui->width < width ? ui->width : width;
|
width = MIN(ui->width, width);
|
||||||
height = ui->height < height ? ui->height : height;
|
height = MIN(ui->height, height);
|
||||||
pum_external &= ui->pum_external;
|
pum_external &= ui->pum_external;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -179,6 +177,16 @@ void ui_refresh(void)
|
|||||||
pum_set_external(pum_external);
|
pum_set_external(pum_external);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void ui_refresh_handler(void **argv)
|
||||||
|
{
|
||||||
|
ui_refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ui_schedule_refresh(void)
|
||||||
|
{
|
||||||
|
loop_schedule(&main_loop, event_create(1, ui_refresh_handler, 0));
|
||||||
|
}
|
||||||
|
|
||||||
void ui_resize(int new_width, int new_height)
|
void ui_resize(int new_width, int new_height)
|
||||||
{
|
{
|
||||||
width = new_width;
|
width = new_width;
|
||||||
@ -252,7 +260,7 @@ void ui_detach_impl(UI *ui)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (--ui_count) {
|
if (--ui_count) {
|
||||||
ui_refresh();
|
ui_schedule_refresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
require('coxpcall')
|
require('coxpcall')
|
||||||
local lfs = require('lfs')
|
local lfs = require('lfs')
|
||||||
local ChildProcessStream = require('nvim.child_process_stream')
|
local ChildProcessStream = require('nvim.child_process_stream')
|
||||||
|
local SocketStream = require('nvim.socket_stream')
|
||||||
|
local TcpStream = require('nvim.tcp_stream')
|
||||||
local Session = require('nvim.session')
|
local Session = require('nvim.session')
|
||||||
local global_helpers = require('test.helpers')
|
local global_helpers = require('test.helpers')
|
||||||
|
|
||||||
@ -223,6 +225,14 @@ local function spawn(argv, merge, env)
|
|||||||
return Session.new(child_stream)
|
return Session.new(child_stream)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Creates a new Session connected by domain socket (named pipe) or TCP.
|
||||||
|
local function connect(file_or_address)
|
||||||
|
local addr, port = string.match(file_or_address, "(.*):(%d+)")
|
||||||
|
local stream = (addr and port) and TcpStream.open(addr, port) or
|
||||||
|
SocketStream.open(file_or_address)
|
||||||
|
return Session.new(stream)
|
||||||
|
end
|
||||||
|
|
||||||
local function clear(...)
|
local function clear(...)
|
||||||
local args = {unpack(nvim_argv)}
|
local args = {unpack(nvim_argv)}
|
||||||
local new_args
|
local new_args
|
||||||
@ -291,8 +301,7 @@ local function write_file(name, text, dont_dedent)
|
|||||||
file:close()
|
file:close()
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Tries to get platform name, from $SYSTEM_NAME, uname,
|
-- Tries to get platform name from $SYSTEM_NAME, uname; fallback is "Windows".
|
||||||
-- fallback is 'Windows'
|
|
||||||
local uname = (function()
|
local uname = (function()
|
||||||
local platform = nil
|
local platform = nil
|
||||||
return (function()
|
return (function()
|
||||||
@ -508,6 +517,7 @@ return function(after_each)
|
|||||||
return {
|
return {
|
||||||
prepend_argv = prepend_argv,
|
prepend_argv = prepend_argv,
|
||||||
clear = clear,
|
clear = clear,
|
||||||
|
connect = connect,
|
||||||
spawn = spawn,
|
spawn = spawn,
|
||||||
dedent = dedent,
|
dedent = dedent,
|
||||||
source = source,
|
source = source,
|
||||||
|
60
test/functional/terminal/api_spec.lua
Normal file
60
test/functional/terminal/api_spec.lua
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
local helpers = require('test.functional.helpers')(after_each)
|
||||||
|
local child_session = require('test.functional.terminal.helpers')
|
||||||
|
local ok = helpers.ok
|
||||||
|
|
||||||
|
if helpers.pending_win32(pending) then return end
|
||||||
|
|
||||||
|
describe('api', function()
|
||||||
|
local screen
|
||||||
|
local socket_name = "Xtest_functional_api.sock"
|
||||||
|
|
||||||
|
before_each(function()
|
||||||
|
helpers.clear()
|
||||||
|
os.remove(socket_name)
|
||||||
|
screen = child_session.screen_setup(0, '["'..helpers.nvim_prog
|
||||||
|
..'", "-u", "NONE", "-i", "NONE", "--cmd", "set noswapfile"]')
|
||||||
|
end)
|
||||||
|
after_each(function()
|
||||||
|
os.remove(socket_name)
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("qa! RPC request during insert-mode", function()
|
||||||
|
-- Start the socket from the child nvim.
|
||||||
|
child_session.feed_data(":echo serverstart('"..socket_name.."')\n")
|
||||||
|
|
||||||
|
-- Wait for socket creation by abusing expect().
|
||||||
|
screen:expect([[
|
||||||
|
{1: } |
|
||||||
|
{4:~ }|
|
||||||
|
{4:~ }|
|
||||||
|
{4:~ }|
|
||||||
|
{5:[No Name] }|
|
||||||
|
]]..socket_name..[[ |
|
||||||
|
{3:-- TERMINAL --} |
|
||||||
|
]])
|
||||||
|
|
||||||
|
local socket_session1 = helpers.connect(socket_name)
|
||||||
|
local socket_session2 = helpers.connect(socket_name)
|
||||||
|
|
||||||
|
child_session.feed_data("i[tui] insert-mode")
|
||||||
|
|
||||||
|
ok(socket_session1:request("nvim_ui_attach", 42, 6, {rgb=true}))
|
||||||
|
ok(socket_session2:request("nvim_ui_attach", 25, 30, {rgb=true}))
|
||||||
|
|
||||||
|
socket_session1:notify("nvim_input", "\n[socket 1] this is more than 25 columns")
|
||||||
|
socket_session2:notify("nvim_input", "\n[socket 2] input")
|
||||||
|
|
||||||
|
screen:expect([[
|
||||||
|
[tui] insert-mode |
|
||||||
|
[socket 1] this is more t{4: }|
|
||||||
|
han 25 columns {4: }|
|
||||||
|
[socket 2] input{1: } {4: }|
|
||||||
|
{5:[No Name] [+] }|
|
||||||
|
{3:-- INSERT --} |
|
||||||
|
{3:-- TERMINAL --} |
|
||||||
|
]])
|
||||||
|
|
||||||
|
socket_session1:request("nvim_command", "qa!")
|
||||||
|
end)
|
||||||
|
end)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user