diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2017-04-25 02:17:15 +0200 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-04-26 03:41:24 +0200 |
commit | 00843902d3472ac4e74106fc06fa60e599914496 (patch) | |
tree | 6d227b71062232086a218af7086d2b31552dc69c /src/nvim/api/ui.c | |
parent | 88023d51238698dd625c26300142d3dbe5770b73 (diff) | |
download | rneovim-00843902d3472ac4e74106fc06fa60e599914496.tar.gz rneovim-00843902d3472ac4e74106fc06fa60e599914496.tar.bz2 rneovim-00843902d3472ac4e74106fc06fa60e599914496.zip |
api/ui: externalize tabline
- Work with a bool[] array parallel to the UIWidget enum.
- Rename some functions.
- Documentation.
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r-- | src/nvim/api/ui.c | 40 |
1 files changed, 32 insertions, 8 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index 28fc641dec..08d285eedc 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -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"); } |