diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/api/ui.c | 11 | ||||
-rw-r--r-- | src/nvim/api/vim.c | 4 | ||||
-rw-r--r-- | src/nvim/ui.c | 31 |
3 files changed, 20 insertions, 26 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index c6e868ca88..5c8ebfb861 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -247,10 +247,9 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictiona void ui_attach(uint64_t channel_id, Integer width, Integer height, Boolean enable_rgb, Error *err) FUNC_API_DEPRECATED_SINCE(1) { - Dictionary opts = ARRAY_DICT_INIT; - PUT(opts, "rgb", BOOLEAN_OBJ(enable_rgb)); + MAXSIZE_TEMP_DICT(opts, 1); + PUT_C(opts, "rgb", BOOLEAN_OBJ(enable_rgb)); nvim_ui_attach(channel_id, width, height, opts, err); - api_free_dictionary(opts); } /// Tells the nvim server if focus was gained or lost by the GUI @@ -1113,9 +1112,3 @@ void remote_ui_event(UI *ui, char *name, Array args) free_ret: arena_mem_free(arena_finish(&arena)); } - -void remote_ui_inspect(UI *ui, Dictionary *info) -{ - UIData *data = ui->data; - PUT(*info, "chan", INTEGER_OBJ((Integer)data->channel_id)); -} diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c index 6b46f579e4..5a106288fd 100644 --- a/src/nvim/api/vim.c +++ b/src/nvim/api/vim.c @@ -1866,10 +1866,10 @@ Dictionary nvim__stats(Arena *arena) /// - "rgb" true if the UI uses RGB colors (false implies |cterm-colors|) /// - "ext_..." Requested UI extensions, see |ui-option| /// - "chan" |channel-id| of remote UI -Array nvim_list_uis(void) +Array nvim_list_uis(Arena *arena) FUNC_API_SINCE(4) { - return ui_array(); + return ui_array(arena); } /// Gets the immediate children of process `pid`. diff --git a/src/nvim/ui.c b/src/nvim/ui.c index ca0ec1e4ab..6420f44640 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -645,34 +645,35 @@ bool ui_has(UIExtension ext) return ui_ext[ext]; } -Array ui_array(void) +Array ui_array(Arena *arena) { - Array all_uis = ARRAY_DICT_INIT; + Array all_uis = arena_array(arena, ui_count); for (size_t i = 0; i < ui_count; i++) { UI *ui = uis[i]; - Dictionary info = ARRAY_DICT_INIT; - PUT(info, "width", INTEGER_OBJ(ui->width)); - PUT(info, "height", INTEGER_OBJ(ui->height)); - PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb)); - PUT(info, "override", BOOLEAN_OBJ(ui->override)); + Dictionary info = arena_dict(arena, 10 + kUIExtCount); + PUT_C(info, "width", INTEGER_OBJ(ui->width)); + PUT_C(info, "height", INTEGER_OBJ(ui->height)); + PUT_C(info, "rgb", BOOLEAN_OBJ(ui->rgb)); + PUT_C(info, "override", BOOLEAN_OBJ(ui->override)); // TUI fields. (`stdin_fd` is intentionally omitted.) - PUT(info, "term_name", CSTR_TO_OBJ(ui->term_name)); + PUT_C(info, "term_name", CSTR_AS_OBJ(ui->term_name)); // term_background is deprecated. Populate with an empty string - PUT(info, "term_background", CSTR_TO_OBJ("")); + PUT_C(info, "term_background", STATIC_CSTR_AS_OBJ("")); - PUT(info, "term_colors", INTEGER_OBJ(ui->term_colors)); - PUT(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty)); - PUT(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty)); + PUT_C(info, "term_colors", INTEGER_OBJ(ui->term_colors)); + PUT_C(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty)); + PUT_C(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty)); for (UIExtension j = 0; j < kUIExtCount; j++) { if (ui_ext_names[j][0] != '_' || ui->ui_ext[j]) { - PUT(info, ui_ext_names[j], BOOLEAN_OBJ(ui->ui_ext[j])); + PUT_C(info, (char *)ui_ext_names[j], BOOLEAN_OBJ(ui->ui_ext[j])); } } - remote_ui_inspect(ui, &info); - ADD(all_uis, DICTIONARY_OBJ(info)); + PUT_C(info, "chan", INTEGER_OBJ((Integer)ui->data->channel_id)); + + ADD_C(all_uis, DICTIONARY_OBJ(info)); } return all_uis; } |