diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2023-02-02 19:02:58 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2023-02-02 19:02:58 +0000 |
commit | b255fa570d8b041e4c81e3454d51e06100c2fa4f (patch) | |
tree | d3b246b467500ca48067ed4a45d2fa53966cd9f1 /src/nvim/ui_client.c | |
parent | eeccad2ff1ae8892fe9e06d733a7b07a166eecb0 (diff) | |
parent | 0bd07bea095a8000cffa4f379c1fa53e009c1143 (diff) | |
download | rneovim-20230125_mix.tar.gz rneovim-20230125_mix.tar.bz2 rneovim-20230125_mix.zip |
Merge branch 'aucmd_textputpost' into 20230125_mix20230125_mix
Diffstat (limited to 'src/nvim/ui_client.c')
-rw-r--r-- | src/nvim/ui_client.c | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 378c0e4831..b5c8dff412 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -23,6 +23,7 @@ #include "nvim/ui_client.h" static TUIData *tui = NULL; +static bool ui_client_is_remote = false; // uncrustify:off #ifdef INCLUDE_GENERATED_DECLARATIONS @@ -66,13 +67,8 @@ uint64_t ui_client_start_server(int argc, char **argv) return channel->id; } -void ui_client_run(bool remote_ui) - FUNC_ATTR_NORETURN +void ui_client_attach(int width, int height, char *term) { - int width, height; - char *term; - tui = tui_start(&width, &height, &term); - MAXSIZE_TEMP_ARRAY(args, 3); ADD_C(args, INTEGER_OBJ(width)); ADD_C(args, INTEGER_OBJ(height)); @@ -82,14 +78,14 @@ void ui_client_run(bool remote_ui) PUT_C(opts, "ext_linegrid", BOOLEAN_OBJ(true)); PUT_C(opts, "ext_termcolors", BOOLEAN_OBJ(true)); if (term) { - PUT(opts, "term_name", STRING_OBJ(cstr_to_string(term))); + PUT_C(opts, "term_name", STRING_OBJ(cstr_as_string(term))); } if (ui_client_bg_response != kNone) { bool is_dark = (ui_client_bg_response == kTrue); PUT_C(opts, "term_background", STRING_OBJ(cstr_as_string(is_dark ? "dark" : "light"))); } PUT_C(opts, "term_colors", INTEGER_OBJ(t_colors)); - if (!remote_ui) { + if (!ui_client_is_remote) { PUT_C(opts, "stdin_tty", BOOLEAN_OBJ(stdin_isatty)); PUT_C(opts, "stdout_tty", BOOLEAN_OBJ(stdout_isatty)); if (ui_client_forward_stdin) { @@ -100,6 +96,23 @@ void ui_client_run(bool remote_ui) rpc_send_event(ui_client_channel_id, "nvim_ui_attach", args); ui_client_attached = true; +} + +void ui_client_detach(void) +{ + rpc_send_event(ui_client_channel_id, "nvim_ui_detach", (Array)ARRAY_DICT_INIT); + ui_client_attached = false; +} + +void ui_client_run(bool remote_ui) + FUNC_ATTR_NORETURN +{ + ui_client_is_remote = remote_ui; + int width, height; + char *term; + tui = tui_start(&width, &height, &term); + + ui_client_attach(width, height, term); // os_exit() will be invoked when the client channel detaches while (true) { |