mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 03:18:16 +00:00
refactor(api): use arena for nvim_list_uis()
This commit is contained in:
@@ -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)
|
void ui_attach(uint64_t channel_id, Integer width, Integer height, Boolean enable_rgb, Error *err)
|
||||||
FUNC_API_DEPRECATED_SINCE(1)
|
FUNC_API_DEPRECATED_SINCE(1)
|
||||||
{
|
{
|
||||||
Dictionary opts = ARRAY_DICT_INIT;
|
MAXSIZE_TEMP_DICT(opts, 1);
|
||||||
PUT(opts, "rgb", BOOLEAN_OBJ(enable_rgb));
|
PUT_C(opts, "rgb", BOOLEAN_OBJ(enable_rgb));
|
||||||
nvim_ui_attach(channel_id, width, height, opts, err);
|
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
|
/// 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:
|
free_ret:
|
||||||
arena_mem_free(arena_finish(&arena));
|
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));
|
|
||||||
}
|
|
||||||
|
@@ -1866,10 +1866,10 @@ Dictionary nvim__stats(Arena *arena)
|
|||||||
/// - "rgb" true if the UI uses RGB colors (false implies |cterm-colors|)
|
/// - "rgb" true if the UI uses RGB colors (false implies |cterm-colors|)
|
||||||
/// - "ext_..." Requested UI extensions, see |ui-option|
|
/// - "ext_..." Requested UI extensions, see |ui-option|
|
||||||
/// - "chan" |channel-id| of remote UI
|
/// - "chan" |channel-id| of remote UI
|
||||||
Array nvim_list_uis(void)
|
Array nvim_list_uis(Arena *arena)
|
||||||
FUNC_API_SINCE(4)
|
FUNC_API_SINCE(4)
|
||||||
{
|
{
|
||||||
return ui_array();
|
return ui_array(arena);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the immediate children of process `pid`.
|
/// Gets the immediate children of process `pid`.
|
||||||
|
@@ -645,34 +645,35 @@ bool ui_has(UIExtension ext)
|
|||||||
return ui_ext[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++) {
|
for (size_t i = 0; i < ui_count; i++) {
|
||||||
UI *ui = uis[i];
|
UI *ui = uis[i];
|
||||||
Dictionary info = ARRAY_DICT_INIT;
|
Dictionary info = arena_dict(arena, 10 + kUIExtCount);
|
||||||
PUT(info, "width", INTEGER_OBJ(ui->width));
|
PUT_C(info, "width", INTEGER_OBJ(ui->width));
|
||||||
PUT(info, "height", INTEGER_OBJ(ui->height));
|
PUT_C(info, "height", INTEGER_OBJ(ui->height));
|
||||||
PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb));
|
PUT_C(info, "rgb", BOOLEAN_OBJ(ui->rgb));
|
||||||
PUT(info, "override", BOOLEAN_OBJ(ui->override));
|
PUT_C(info, "override", BOOLEAN_OBJ(ui->override));
|
||||||
|
|
||||||
// TUI fields. (`stdin_fd` is intentionally omitted.)
|
// 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
|
// 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_C(info, "term_colors", INTEGER_OBJ(ui->term_colors));
|
||||||
PUT(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty));
|
PUT_C(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty));
|
||||||
PUT(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty));
|
PUT_C(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty));
|
||||||
|
|
||||||
for (UIExtension j = 0; j < kUIExtCount; j++) {
|
for (UIExtension j = 0; j < kUIExtCount; j++) {
|
||||||
if (ui_ext_names[j][0] != '_' || ui->ui_ext[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);
|
PUT_C(info, "chan", INTEGER_OBJ((Integer)ui->data->channel_id));
|
||||||
ADD(all_uis, DICTIONARY_OBJ(info));
|
|
||||||
|
ADD_C(all_uis, DICTIONARY_OBJ(info));
|
||||||
}
|
}
|
||||||
return all_uis;
|
return all_uis;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user