nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Nano-devel] [PATCH] general: detect in a better way whether we're runni


From: Benno Schulenberg
Subject: [Nano-devel] [PATCH] general: detect in a better way whether we're running on a Linux console
Date: Thu, 1 Feb 2018 19:43:21 +0100

Suggested-by: Mike Frysinger <address@hidden>
---
 src/nano.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/nano.c b/src/nano.c
index 12543dd4..02cb4503 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -26,7 +26,7 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <getopt.h>
-#ifndef NANO_TINY
+#if defined(__linux__) || !defined(NANO_TINY)
 #include <sys/ioctl.h>
 #endif
 #ifdef ENABLE_UTF8
@@ -38,6 +38,9 @@
 #include <termios.h>
 #endif
 #include <unistd.h>
+#ifdef __linux__
+#include <sys/vt.h>
+#endif
 
 #ifdef ENABLE_MOUSE
 static int oldinterval = -1;
@@ -1988,8 +1991,10 @@ int main(int argc, char **argv)
        };
 
 #ifdef __linux__
+       struct vt_stat dummy;
+
        /* Check whether we're running on a Linux console. */
-       console = (getenv("DISPLAY") == NULL);
+       console = (ioctl(0, VT_GETSTATE, &dummy) == 0);
 #endif
 
        /* Back up the terminal settings so that they can be restored. */
-- 
2.14.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]