From b97ec93748902c90f25524116d3d189f1b263474 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Wed, 8 Feb 2023 17:12:23 +0100 Subject: make ls cooler --- lib/tctl/tctl.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/tctl/tctl.c') diff --git a/lib/tctl/tctl.c b/lib/tctl/tctl.c index 54034f4..187d1a9 100644 --- a/lib/tctl/tctl.c +++ b/lib/tctl/tctl.c @@ -3,16 +3,24 @@ #define GET_WIN_SIZE 0x5413 #define SET_WIN_SIZE 0x5414 +#define TC_GET_ATTR 0x5401 window_size_t tctl_get_window_size() { window_size_t ws; - ioctl(0, GET_WIN_SIZE, &ws); + ioctl(1, GET_WIN_SIZE, &ws); return ws; } void tctl_set_window_size(window_size_t size) { - ioctl(0, SET_WIN_SIZE, &size); + ioctl(1, SET_WIN_SIZE, &size); +} + + +int isatty() +{ + termios_t term; + return ioctl(1, TC_GET_ATTR, &term) == 0; } -- cgit v1.2.3-70-g09d2