From 0231265c8cf8c13f317bbddcfcbac2639e7022cd Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Wed, 12 Jun 2024 19:55:28 -0500 Subject: fix(tui): skip TUI in ui_rgb_attached (#29096) The ui_rgb_attached function determines if any UI is attached which supports RGB (truecolor). We determine if the TUI supports RGB via the 'termguicolors' option which is checked at the beginning of this function. If the TUI does not support RGB ('termguicolors' is unset), we check to see if any _other_ UI is attached which supports RGB. Normally, the TUI's "rgb" flag and the 'termguicolors' option are the same. However, they may differ during startup when the "rgb" flag is set by tui/tui.c to indicate to the core that the terminal emulator supports truecolor. The 'termguicolors' option is not actually set until _defaults.lua runs. --- src/nvim/ui.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 9bb66b886e..314d322a68 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; } } -- cgit From ff85e54939b0aca34a779a2b6381d09db1858b29 Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Wed, 18 Sep 2024 04:14:06 -0700 Subject: feat(tui): builtin UI (TUI) sets client info #30397 Problem: The default builtin UI client does not declare its client info. This reduces discoverability and makes it difficult for plugins to identify the UI. Solution: - Call nvim_set_client_info after attaching, as recommended by `:help dev-ui`. - Also set the "pid" field. - Also change `ui_active()` to return a count. Not directly relevant to this commit, but will be useful later. --- src/nvim/ui.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 314d322a68..587124fab0 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -182,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) @@ -197,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]; -- cgit From 737f58e23230ea14f1648ac1fc7f442ea0f8563c Mon Sep 17 00:00:00 2001 From: "Justin M. Keyes" Date: Fri, 20 Sep 2024 07:34:50 +0200 Subject: refactor(api)!: rename Dictionary => Dict In the api_info() output: :new|put =map(filter(api_info().functions, '!has_key(v:val,''deprecated_since'')'), 'v:val') ... {'return_type': 'ArrayOf(Integer, 2)', 'name': 'nvim_win_get_position', 'method': v:true, 'parameters': [['Window', 'window']], 'since': 1} The `ArrayOf(Integer, 2)` return type didn't break clients when we added it, which is evidence that clients don't use the `return_type` field, thus renaming Dictionary => Dict in api_info() is not (in practice) a breaking change. --- src/nvim/ui.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/nvim/ui.c') diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 587124fab0..365aa5c74f 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -659,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)); @@ -682,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; } -- cgit