mirror of
https://github.com/neovim/neovim.git
synced 2025-10-20 00:31:49 +00:00
feat(ui): :connect command #34586
Add the `:connect <address>` command which connects the currently running TUI to the server at the given address.
This commit is contained in:
@@ -281,6 +281,38 @@ void ui_client_event_raw_line(GridLineEvent *g)
|
||||
(const schar_T *)grid_line_buf_char, grid_line_buf_attr);
|
||||
}
|
||||
|
||||
void ui_client_event_connect(Array args)
|
||||
{
|
||||
if (args.size < 1 || args.items[0].type != kObjectTypeString) {
|
||||
ELOG("Error handling UI event 'connect'");
|
||||
return;
|
||||
}
|
||||
|
||||
char *server_addr = args.items[0].data.string.data;
|
||||
multiqueue_put(main_loop.fast_events, channel_connect_event, server_addr);
|
||||
}
|
||||
|
||||
static void channel_connect_event(void **argv)
|
||||
{
|
||||
char *server_addr = argv[0];
|
||||
|
||||
const char *err = "";
|
||||
bool is_tcp = !!strrchr(server_addr, ':');
|
||||
CallbackReader on_data = CALLBACK_READER_INIT;
|
||||
uint64_t chan = channel_connect(is_tcp, server_addr, true, on_data, 50, &err);
|
||||
|
||||
if (!strequal(err, "")) {
|
||||
ELOG("Error handling UI event 'connect': %s", err);
|
||||
return;
|
||||
}
|
||||
|
||||
ui_client_channel_id = chan;
|
||||
ui_client_is_remote = true;
|
||||
ui_client_attach(tui_width, tui_height, tui_term, tui_rgb);
|
||||
|
||||
ELOG("Connected to channel: %" PRId64, chan);
|
||||
}
|
||||
|
||||
/// When a "restart" UI event is received, its arguments are saved here when
|
||||
/// waiting for the server to exit.
|
||||
static Array restart_args = ARRAY_DICT_INIT;
|
||||
|
Reference in New Issue
Block a user