mirror of
https://github.com/neovim/neovim.git
synced 2025-10-02 07:58:35 +00:00
ui: refactor ui options
This commit is contained in:
@@ -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)
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user