aboutsummaryrefslogtreecommitdiff
path: root/lib/interestingtimes.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/interestingtimes.c')
-rw-r--r--lib/interestingtimes.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/interestingtimes.c b/lib/interestingtimes.c
index cea5039f..85b8eb4c 100644
--- a/lib/interestingtimes.c
+++ b/lib/interestingtimes.c
@@ -5,6 +5,15 @@
#include "toys.h"
+int xgettty(void)
+{
+ int i, j;
+
+ for (i = 0; i<3; i++) if (isatty(j = (i+1)%3)) return j;
+
+ return xopen("/dev/tty", O_RDWR);
+}
+
// Quick and dirty query size of terminal, doesn't do ANSI probe fallback.
// set x=80 y=25 before calling to provide defaults. Returns 0 if couldn't
// determine size.