aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/api')
-rw-r--r--src/nvim/api/private/helpers.c7
-rw-r--r--src/nvim/api/ui.c30
2 files changed, 20 insertions, 17 deletions
diff --git a/src/nvim/api/private/helpers.c b/src/nvim/api/private/helpers.c
index 9baa996560..65c306d4b1 100644
--- a/src/nvim/api/private/helpers.c
+++ b/src/nvim/api/private/helpers.c
@@ -26,6 +26,7 @@
#include "nvim/version.h"
#include "nvim/lib/kvec.h"
#include "nvim/getchar.h"
+#include "nvim/ui.h"
/// Helper structure for vim_to_object
typedef struct {
@@ -955,6 +956,12 @@ static void init_ui_event_metadata(Dictionary *metadata)
msgpack_rpc_to_object(&unpacked.data, &ui_events);
msgpack_unpacked_destroy(&unpacked);
PUT(*metadata, "ui_events", ui_events);
+ Array ui_options = ARRAY_DICT_INIT;
+ ADD(ui_options, STRING_OBJ(cstr_to_string("rgb")));
+ for (UIExtension i = 0; i < kUIExtCount; i++) {
+ ADD(ui_options, STRING_OBJ(cstr_to_string(ui_ext_names[i])));
+ }
+ PUT(*metadata, "ui_options", ARRAY_OBJ(ui_options));
}
static void init_error_type_metadata(Dictionary *metadata)
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");