aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ui.c
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
commit9be89f131f87608f224f0ee06d199fcd09d32176 (patch)
tree11022dcfa9e08cb4ac5581b16734196128688d48 /src/nvim/ui.c
parentff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff)
parent88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff)
downloadrneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r--src/nvim/ui.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 9bb66b886e..365aa5c74f 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -144,11 +144,15 @@ void ui_free_all_mem(void)
/// Returns true if any `rgb=true` UI is attached.
bool ui_rgb_attached(void)
{
- if (!headless_mode && p_tgc) {
+ if (p_tgc) {
return true;
}
for (size_t i = 0; i < ui_count; i++) {
- if (uis[i]->rgb) {
+ // We do not consider the TUI in this loop because we already checked for 'termguicolors' at the
+ // beginning of this function. In this loop, we are checking to see if any _other_ UIs which
+ // support RGB are attached.
+ bool tui = uis[i]->stdin_tty || uis[i]->stdout_tty;
+ if (!tui && uis[i]->rgb) {
return true;
}
}
@@ -178,9 +182,10 @@ bool ui_override(void)
return false;
}
-bool ui_active(void)
+/// Gets the number of UIs connected to this server.
+size_t ui_active(void)
{
- return ui_count > 0;
+ return ui_count;
}
void ui_refresh(void)
@@ -193,7 +198,7 @@ void ui_refresh(void)
int height = INT_MAX;
bool ext_widgets[kUIExtCount];
bool inclusive = ui_override();
- memset(ext_widgets, ui_active(), ARRAY_SIZE(ext_widgets));
+ memset(ext_widgets, !!ui_active(), ARRAY_SIZE(ext_widgets));
for (size_t i = 0; i < ui_count; i++) {
RemoteUI *ui = uis[i];
@@ -654,7 +659,7 @@ Array ui_array(Arena *arena)
Array all_uis = arena_array(arena, ui_count);
for (size_t i = 0; i < ui_count; i++) {
RemoteUI *ui = uis[i];
- Dictionary info = arena_dict(arena, 10 + kUIExtCount);
+ Dict info = arena_dict(arena, 10 + kUIExtCount);
PUT_C(info, "width", INTEGER_OBJ(ui->width));
PUT_C(info, "height", INTEGER_OBJ(ui->height));
PUT_C(info, "rgb", BOOLEAN_OBJ(ui->rgb));
@@ -677,7 +682,7 @@ Array ui_array(Arena *arena)
}
PUT_C(info, "chan", INTEGER_OBJ((Integer)ui->channel_id));
- ADD_C(all_uis, DICTIONARY_OBJ(info));
+ ADD_C(all_uis, DICT_OBJ(info));
}
return all_uis;
}