diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2018-02-13 13:45:49 +0100 |
---|---|---|
committer | Björn Linse <bjorn.linse@gmail.com> | 2018-02-13 20:48:51 +0100 |
commit | 6e5cb0debd23693175bd05409d3f1af4015567df (patch) | |
tree | da2298632595dc2d42c921a323ebd63978c27b82 /src/nvim/api/ui.c | |
parent | 0f1bc5ddceb50ca8f96d91aabf8157d9758af0cd (diff) | |
download | rneovim-6e5cb0debd23693175bd05409d3f1af4015567df.tar.gz rneovim-6e5cb0debd23693175bd05409d3f1af4015567df.tar.bz2 rneovim-6e5cb0debd23693175bd05409d3f1af4015567df.zip |
ui: refactor ui options
Diffstat (limited to 'src/nvim/api/ui.c')
-rw-r--r-- | src/nvim/api/ui.c | 30 |
1 files changed, 13 insertions, 17 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c index e53a45bd93..4870c3fb8a 100644 --- a/src/nvim/api/ui.c +++ b/src/nvim/api/ui.c @@ -176,18 +176,6 @@ void nvim_ui_set_option(uint64_t channel_id, String name, static void ui_set_option(UI *ui, String name, Object value, Error *error) { -#define UI_EXT_OPTION(o, e) \ - do { \ - if (strequal(name.data, #o)) { \ - if (value.type != kObjectTypeBoolean) { \ - api_set_error(error, kErrorTypeValidation, #o " must be a Boolean"); \ - return; \ - } \ - ui->ui_ext[(e)] = value.data.boolean; \ - return; \ - } \ - } while (0) - if (strequal(name.data, "rgb")) { if (value.type != kObjectTypeBoolean) { api_set_error(error, kErrorTypeValidation, "rgb must be a Boolean"); @@ -197,13 +185,21 @@ static void ui_set_option(UI *ui, String name, Object value, Error *error) return; } - UI_EXT_OPTION(ext_cmdline, kUICmdline); - UI_EXT_OPTION(ext_popupmenu, kUIPopupmenu); - UI_EXT_OPTION(ext_tabline, kUITabline); - UI_EXT_OPTION(ext_wildmenu, kUIWildmenu); + for (UIExtension i = 0; i < kUIExtCount; i++) { + if (strequal(name.data, ui_ext_names[i])) { + if (value.type != kObjectTypeBoolean) { + snprintf((char *)IObuff, IOSIZE, "%s must be a Boolean", + ui_ext_names[i]); + api_set_error(error, kErrorTypeValidation, (char *)IObuff); + return; + } + ui->ui_ext[i] = value.data.boolean; + return; + } + } if (strequal(name.data, "popupmenu_external")) { - // LEGACY: Deprecated option, use `ui_ext` instead. + // LEGACY: Deprecated option, use `ext_cmdline` instead. if (value.type != kObjectTypeBoolean) { api_set_error(error, kErrorTypeValidation, "popupmenu_external must be a Boolean"); |