aboutsummaryrefslogtreecommitdiff
path: root/src/nvim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim')
-rw-r--r--src/nvim/api/ui.c1
-rw-r--r--src/nvim/eval/funcs.c4
-rw-r--r--src/nvim/ui.c16
-rw-r--r--src/nvim/ui.h1
4 files changed, 17 insertions, 5 deletions
diff --git a/src/nvim/api/ui.c b/src/nvim/api/ui.c
index 00fd2781ff..a8f5d2e070 100644
--- a/src/nvim/api/ui.c
+++ b/src/nvim/api/ui.c
@@ -352,7 +352,6 @@ static void ui_set_option(UI *ui, bool init, String name, Object value, Error *e
});
stdin_fd = (int)value.data.integer;
- ui->stdin_fd = (int)value.data.integer;
return;
}
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index 1baf96e281..d97f7b6d35 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -3228,7 +3228,9 @@ static void f_has(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
}
if (!n) {
- if (STRNICMP(name, "patch", 5) == 0) {
+ if (STRNICMP(name, "gui_running", 11) == 0) {
+ n = ui_gui_attached();
+ } else if (STRNICMP(name, "patch", 5) == 0) {
if (name[5] == '-'
&& strlen(name) >= 11
&& ascii_isdigit(name[6])
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));
diff --git a/src/nvim/ui.h b/src/nvim/ui.h
index c1377f56b4..dc0ccc73ea 100644
--- a/src/nvim/ui.h
+++ b/src/nvim/ui.h
@@ -107,7 +107,6 @@ struct ui_t {
char *term_name;
char *term_background;
int term_colors;
- int stdin_fd;
bool stdin_tty;
bool stdout_tty;