aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r--src/nvim/ui.c51
1 files changed, 19 insertions, 32 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 6dcc3de1b0..713dffb46c 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -47,6 +47,7 @@
#define MAX_UI_COUNT 16
static UI *uis[MAX_UI_COUNT];
+static bool ui_ext[UI_WIDGETS] = { 0 };
static size_t ui_count = 0;
static int row = 0, col = 0;
static struct {
@@ -58,10 +59,6 @@ static int busy = 0;
static int height, width;
static int old_mode_idx = -1;
-static bool tabline_external = false;
-static bool cmdline_external = false;
-static bool wildmenu_external = false;
-
// UI_CALL invokes a function on all registered UI instances. The functions can
// have 0-5 arguments (configurable by SELECT_NTH).
//
@@ -170,21 +167,25 @@ void ui_refresh(void)
}
int width = INT_MAX, height = INT_MAX;
- bool pum_external = true;
- bool tabline_external = true;
+ bool ext_widgets[UI_WIDGETS];
+ for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
+ ext_widgets[i] = true;
+ }
for (size_t i = 0; i < ui_count; i++) {
UI *ui = uis[i];
width = MIN(ui->width, width);
height = MIN(ui->height, height);
- pum_external &= ui->pum_external;
- tabline_external &= ui->tabline_external;
+ for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
+ ext_widgets[i] &= ui->ui_ext[i];
+ }
}
row = col = 0;
screen_resize(width, height);
- pum_set_external(pum_external);
- ui_set_widget_external(kUITabline, tabline_external);
+ for (UIWidget i = 0; (int)i < UI_WIDGETS; i++) {
+ ui_set_external(i, ext_widgets[i]);
+ }
ui_mode_info_set();
old_mode_idx = -1;
ui_cursor_shape();
@@ -564,30 +565,16 @@ void ui_cursor_shape(void)
conceal_check_cursur_line();
}
-bool ui_is_widget_external(UIWidget widget)
+/// Returns true if `widget` is externalized.
+bool ui_is_external(UIWidget widget)
{
- switch (widget) {
- case kUITabline:
- return tabline_external;
- case kUICmdline:
- return cmdline_external;
- case kUIWildmenu:
- return wildmenu_external;
- }
- return false;
+ return ui_ext[widget];
}
-void ui_set_widget_external(UIWidget widget, bool external)
+/// Sets `widget` as "external".
+/// Such widgets are not drawn by Nvim; external UIs are expected to handle
+/// higher-level UI events and present the data.
+void ui_set_external(UIWidget widget, bool external)
{
- switch (widget) {
- case kUITabline:
- tabline_external = external;
- break;
- case kUICmdline:
- cmdline_external = external;
- break;
- case kUIWildmenu:
- wildmenu_external = external;
- break;
- }
+ ui_ext[widget] = external;
}