mirror of
https://github.com/neovim/neovim.git
synced 2025-09-23 03:28:33 +00:00
api/ui: externalize tabline
- Work with a bool[] array parallel to the UIWidget enum. - Rename some functions. - Documentation.
This commit is contained in:
@@ -68,8 +68,6 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
||||
ui->width = (int)width;
|
||||
ui->height = (int)height;
|
||||
ui->rgb = true;
|
||||
ui->pum_external = false;
|
||||
ui->tabline_external = false;
|
||||
ui->resize = remote_ui_resize;
|
||||
ui->clear = remote_ui_clear;
|
||||
ui->eol_clear = remote_ui_eol_clear;
|
||||
@@ -96,6 +94,8 @@ void nvim_ui_attach(uint64_t channel_id, Integer width, Integer height,
|
||||
ui->set_icon = remote_ui_set_icon;
|
||||
ui->event = remote_ui_event;
|
||||
|
||||
memset(ui->ui_ext, 0, sizeof(ui->ui_ext));
|
||||
|
||||
for (size_t i = 0; i < options.size; i++) {
|
||||
ui_set_option(ui, options.items[i].key, options.items[i].value, err);
|
||||
if (ERROR_SET(err)) {
|
||||
@@ -171,7 +171,8 @@ void nvim_ui_set_option(uint64_t channel_id, String name,
|
||||
}
|
||||
}
|
||||
|
||||
static void ui_set_option(UI *ui, String name, Object value, Error *error) {
|
||||
static void ui_set_option(UI *ui, String name, Object value, Error *error)
|
||||
{
|
||||
if (strequal(name.data, "rgb")) {
|
||||
if (value.type != kObjectTypeBoolean) {
|
||||
api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean");
|
||||
@@ -179,19 +180,42 @@ static void ui_set_option(UI *ui, String name, Object value, Error *error) {
|
||||
}
|
||||
ui->rgb = value.data.boolean;
|
||||
} else if (strequal(name.data, "popupmenu_external")) {
|
||||
// LEGACY: Deprecated option, use `ui_ext` instead.
|
||||
if (value.type != kObjectTypeBoolean) {
|
||||
api_set_error(error, kErrorTypeValidation,
|
||||
"popupmenu_external must be a Boolean");
|
||||
return;
|
||||
}
|
||||
ui->pum_external = value.data.boolean;
|
||||
} else if (strequal(name.data, "tabline_external")) {
|
||||
if (value.type != kObjectTypeBoolean) {
|
||||
ui->ui_ext[kUIPopupmenu] = value.data.boolean;
|
||||
} else if (strequal(name.data, "ui_ext")) {
|
||||
if (value.type != kObjectTypeArray) {
|
||||
api_set_error(error, kErrorTypeValidation,
|
||||
"tabline_external must be a Boolean");
|
||||
"ui_ext must be an Array");
|
||||
return;
|
||||
}
|
||||
ui->tabline_external = value.data.boolean;
|
||||
|
||||
for (size_t i = 0; i < value.data.array.size; i++) {
|
||||
Object item = value.data.array.items[i];
|
||||
if (item.type != kObjectTypeString) {
|
||||
api_set_error(error, kErrorTypeValidation,
|
||||
"ui_ext: item must be a String");
|
||||
return;
|
||||
}
|
||||
char *name = item.data.string.data;
|
||||
if (strequal(name, "cmdline")) {
|
||||
ui->ui_ext[kUICmdline] = true;
|
||||
} else if (strequal(name, "popupmenu")) {
|
||||
ui->ui_ext[kUIPopupmenu] = true;
|
||||
} else if (strequal(name, "tabline")) {
|
||||
ui->ui_ext[kUITabline] = true;
|
||||
} else if (strequal(name, "wildmenu")) {
|
||||
ui->ui_ext[kUIWildmenu] = true;
|
||||
} else {
|
||||
api_set_error(error, kErrorTypeValidation,
|
||||
"ui_ext: unknown widget: %s", name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
api_set_error(error, kErrorTypeValidation, "No such ui option");
|
||||
}
|
||||
|
Reference in New Issue
Block a user