diff options
Diffstat (limited to 'src/nvim/ui_client.c')
-rw-r--r-- | src/nvim/ui_client.c | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/nvim/ui_client.c b/src/nvim/ui_client.c index 30f44d182d..4f36cae4b2 100644 --- a/src/nvim/ui_client.c +++ b/src/nvim/ui_client.c @@ -5,23 +5,29 @@ #include <stdlib.h> #include "nvim/api/keysets_defs.h" +#include "nvim/api/private/defs.h" #include "nvim/api/private/dispatch.h" #include "nvim/api/private/helpers.h" #include "nvim/channel.h" +#include "nvim/channel_defs.h" #include "nvim/eval.h" #include "nvim/eval/typval_defs.h" -#include "nvim/event/loop.h" -#include "nvim/func_attr.h" +#include "nvim/event/multiqueue.h" #include "nvim/globals.h" #include "nvim/highlight.h" +#include "nvim/highlight_defs.h" #include "nvim/log.h" #include "nvim/main.h" #include "nvim/memory.h" +#include "nvim/memory_defs.h" #include "nvim/msgpack_rpc/channel.h" +#include "nvim/msgpack_rpc/channel_defs.h" #include "nvim/os/os_defs.h" #include "nvim/tui/tui.h" +#include "nvim/tui/tui_defs.h" #include "nvim/ui.h" #include "nvim/ui_client.h" +#include "nvim/ui_defs.h" #ifdef MSWIN # include "nvim/os/os_win_console.h" @@ -56,6 +62,9 @@ uint64_t ui_client_start_server(int argc, char **argv) CALLBACK_READER_INIT, on_err, CALLBACK_NONE, false, true, true, false, kChannelStdinPipe, NULL, 0, 0, NULL, &exit_status); + if (!channel) { + return 0; + } // If stdin is not a pty, it is forwarded to the client. // Replace stdin in the TUI process with the tty fd. @@ -71,14 +80,14 @@ uint64_t ui_client_start_server(int argc, char **argv) return channel->id; } -void ui_client_attach(int width, int height, char *term) +void ui_client_attach(int width, int height, char *term, bool rgb) { MAXSIZE_TEMP_ARRAY(args, 3); ADD_C(args, INTEGER_OBJ(width)); ADD_C(args, INTEGER_OBJ(height)); MAXSIZE_TEMP_DICT(opts, 9); - PUT_C(opts, "rgb", BOOLEAN_OBJ(true)); + PUT_C(opts, "rgb", BOOLEAN_OBJ(rgb)); PUT_C(opts, "ext_linegrid", BOOLEAN_OBJ(true)); PUT_C(opts, "ext_termcolors", BOOLEAN_OBJ(true)); if (term) { @@ -112,9 +121,10 @@ void ui_client_run(bool remote_ui) ui_client_is_remote = remote_ui; int width, height; char *term; - tui_start(&tui, &width, &height, &term); + bool rgb; + tui_start(&tui, &width, &height, &term, &rgb); - ui_client_attach(width, height, term); + ui_client_attach(width, height, term, rgb); // os_exit() will be invoked when the client channel detaches while (true) { @@ -163,12 +173,19 @@ Object handle_ui_client_redraw(uint64_t channel_id, Array args, Arena *arena, Er static HlAttrs ui_client_dict2hlattrs(Dictionary d, bool rgb) { Error err = ERROR_INIT; - Dict(highlight) dict = { 0 }; + Dict(highlight) dict = KEYDICT_INIT; if (!api_dict_to_keydict(&dict, KeyDict_highlight_get_field, d, &err)) { // TODO(bfredl): log "err" return HLATTRS_INIT; } - return dict2hlattrs(&dict, rgb, NULL, &err); + + HlAttrs attrs = dict2hlattrs(&dict, rgb, NULL, &err); + + if (HAS_KEY(&dict, highlight, url)) { + attrs.url = tui_add_url(tui, dict.url.data); + } + + return attrs; } void ui_client_event_grid_resize(Array args) @@ -203,7 +220,9 @@ void ui_client_event_grid_line(Array args) void ui_client_event_raw_line(GridLineEvent *g) { - int grid = g->args[0], row = g->args[1], startcol = g->args[2]; + int grid = g->args[0]; + int row = g->args[1]; + int startcol = g->args[2]; Integer endcol = startcol + g->coloff; Integer clearcol = endcol + g->clear_width; LineFlags lineflags = g->wrap ? kLineFlagWrap : 0; @@ -211,3 +230,12 @@ void ui_client_event_raw_line(GridLineEvent *g) tui_raw_line(tui, grid, row, startcol, endcol, clearcol, g->cur_attr, lineflags, (const schar_T *)grid_line_buf_char, grid_line_buf_attr); } + +#ifdef EXITFREE +void ui_client_free_all_mem(void) +{ + tui_free_all_mem(tui); + xfree(grid_line_buf_char); + xfree(grid_line_buf_attr); +} +#endif |