mirror of
https://github.com/neovim/neovim.git
synced 2025-10-08 19:06:31 +00:00
feat(api): more fields in nvim_list_uis
Problem: nvim_list_uis does not report all ":help ui-option" fields. Solution: Store ":help ui-option" fields on the `UI` object and update ui_array.
This commit is contained in:
@@ -113,6 +113,10 @@ void remote_ui_disconnect(uint64_t channel_id)
|
||||
kv_destroy(data->call_buf);
|
||||
pmap_del(uint64_t)(&connected_uis, channel_id);
|
||||
ui_detach_impl(ui, channel_id);
|
||||
|
||||
// Destroy `ui`.
|
||||
XFREE_CLEAR(ui->term_name);
|
||||
XFREE_CLEAR(ui->term_background);
|
||||
xfree(ui);
|
||||
}
|
||||
|
||||
@@ -163,15 +167,9 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height, Dictiona
|
||||
UI *ui = xcalloc(1, sizeof(UI));
|
||||
ui->width = (int)width;
|
||||
ui->height = (int)height;
|
||||
ui->pum_nlines = 0;
|
||||
ui->pum_pos = false;
|
||||
ui->pum_width = 0.0;
|
||||
ui->pum_height = 0.0;
|
||||
ui->pum_row = -1.0;
|
||||
ui->pum_col = -1.0;
|
||||
ui->rgb = true;
|
||||
ui->override = false;
|
||||
|
||||
CLEAR_FIELD(ui->ui_ext);
|
||||
|
||||
for (size_t i = 0; i < options.size; i++) {
|
||||
@@ -320,6 +318,7 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
|
||||
return;
|
||||
});
|
||||
set_tty_option("term", string_to_cstr(value.data.string));
|
||||
ui->term_name = string_to_cstr(value.data.string);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -328,6 +327,7 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
|
||||
return;
|
||||
});
|
||||
t_colors = (int)value.data.integer;
|
||||
ui->term_colors = (int)value.data.integer;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -336,6 +336,7 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
|
||||
return;
|
||||
});
|
||||
set_tty_background(value.data.string.data);
|
||||
ui->term_background = string_to_cstr(value.data.string);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -351,6 +352,7 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
|
||||
});
|
||||
|
||||
stdin_fd = (int)value.data.integer;
|
||||
ui->stdin_fd = (int)value.data.integer;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -359,6 +361,7 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
|
||||
return;
|
||||
});
|
||||
stdin_isatty = value.data.boolean;
|
||||
ui->stdin_tty = value.data.boolean;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -367,6 +370,7 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
|
||||
return;
|
||||
});
|
||||
stdout_isatty = value.data.boolean;
|
||||
ui->stdout_tty = value.data.boolean;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -598,6 +598,15 @@ Array ui_array(void)
|
||||
PUT(info, "height", INTEGER_OBJ(ui->height));
|
||||
PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb));
|
||||
PUT(info, "override", BOOLEAN_OBJ(ui->override));
|
||||
|
||||
// TUI fields.
|
||||
PUT(info, "term_name", STRING_OBJ(cstr_to_string(ui->term_name)));
|
||||
PUT(info, "term_background", STRING_OBJ(cstr_to_string(ui->term_background)));
|
||||
PUT(info, "term_colors", INTEGER_OBJ(ui->term_colors));
|
||||
PUT(info, "stdin_fd", INTEGER_OBJ(ui->stdin_fd));
|
||||
PUT(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty));
|
||||
PUT(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]));
|
||||
|
@@ -103,6 +103,14 @@ struct ui_t {
|
||||
double pum_height;
|
||||
double pum_width;
|
||||
|
||||
// TUI fields.
|
||||
char *term_name;
|
||||
char *term_background;
|
||||
int term_colors;
|
||||
int stdin_fd;
|
||||
bool stdin_tty;
|
||||
bool stdout_tty;
|
||||
|
||||
// TODO(bfredl): integrate into struct!
|
||||
UIData data[1];
|
||||
};
|
||||
|
@@ -1,6 +1,8 @@
|
||||
// This is an open source non-commercial project. Dear PVS-Studio, please check
|
||||
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||
|
||||
/// Nvim's own UI client, which attaches to a child or remote Nvim server.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
Reference in New Issue
Block a user