diff options
Diffstat (limited to 'src/nvim/ui.c')
-rw-r--r-- | src/nvim/ui.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/nvim/ui.c b/src/nvim/ui.c index 6c95579b47..ce1a57350a 100644 --- a/src/nvim/ui.c +++ b/src/nvim/ui.c @@ -134,6 +134,7 @@ void ui_free_all_mem(void) } #endif +/// Returns true if any `rgb=true` UI is attached. bool ui_rgb_attached(void) { if (!headless_mode && p_tgc) { @@ -147,6 +148,18 @@ bool ui_rgb_attached(void) return false; } +/// Returns true if a GUI is attached. +bool ui_gui_attached(void) +{ + for (size_t i = 0; i < ui_count; i++) { + bool tui = uis[i]->stdin_tty || uis[i]->stdout_tty; + if (!tui) { + return true; + } + } + return false; +} + /// Returns true if any UI requested `override=true`. bool ui_override(void) { @@ -599,11 +612,10 @@ Array ui_array(void) PUT(info, "rgb", BOOLEAN_OBJ(ui->rgb)); PUT(info, "override", BOOLEAN_OBJ(ui->override)); - // TUI fields. + // TUI fields. (`stdin_fd` is intentionally omitted.) PUT(info, "term_name", STRING_OBJ(cstr_to_string(ui->term_name))); PUT(info, "term_background", STRING_OBJ(cstr_to_string(ui->term_background))); PUT(info, "term_colors", INTEGER_OBJ(ui->term_colors)); - PUT(info, "stdin_fd", INTEGER_OBJ(ui->stdin_fd)); PUT(info, "stdin_tty", BOOLEAN_OBJ(ui->stdin_tty)); PUT(info, "stdout_tty", BOOLEAN_OBJ(ui->stdout_tty)); |