aboutsummaryrefslogtreecommitdiff
path: root/lib/tctl
diff options
context:
space:
mode:
authorNathan Reiner <nathan@nathanreiner.xyz>2023-02-08 17:12:23 +0100
committerNathan Reiner <nathan@nathanreiner.xyz>2023-02-08 17:12:23 +0100
commitb97ec93748902c90f25524116d3d189f1b263474 (patch)
treec1ef2d49937c0e5df28fefe4e88222783adaf3cf /lib/tctl
parent262322f9742ee925fe135038a9bbb631acd56b36 (diff)
make ls cooler
Diffstat (limited to 'lib/tctl')
-rw-r--r--lib/tctl/tctl.c12
-rw-r--r--lib/tctl/tctl.h12
2 files changed, 22 insertions, 2 deletions
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;
}
diff --git a/lib/tctl/tctl.h b/lib/tctl/tctl.h
index d106818..bdcdb66 100644
--- a/lib/tctl/tctl.h
+++ b/lib/tctl/tctl.h
@@ -8,7 +8,19 @@ typedef struct {
unsigned short int ws_ypixel;
} window_size_t;
+typedef struct {
+ unsigned int c_iflag;
+ unsigned int c_oflag;
+ unsigned int c_cflag;
+ unsigned int c_lflag;
+ unsigned char c_line;
+ unsigned char c_cc[32];
+ unsigned int c_ispeed;
+ unsigned int c_ospeed;
+} termios_t;
+
window_size_t tctl_get_window_size();
void tctl_set_window_size(window_size_t size);
+int isatty();
#endif