]> gitweb.ps.run Git - iftint/commitdiff
termsize.c
authorPatrick <patrick.schoenberger@posteo.de>
Sat, 29 Jul 2023 12:31:26 +0000 (14:31 +0200)
committerPatrick <patrick.schoenberger@posteo.de>
Sat, 29 Jul 2023 12:31:26 +0000 (14:31 +0200)
termsize.c [new file with mode: 0644]

diff --git a/termsize.c b/termsize.c
new file mode 100644 (file)
index 0000000..83a0158
--- /dev/null
@@ -0,0 +1,14 @@
+#include <sys/ioctl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+int main (int argc, char **argv)
+{
+    struct winsize w;
+    ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
+
+    printf ("lines %d\n", w.ws_row);
+    printf ("columns %d\n", w.ws_col);
+    return 0;  // make sure your main returns int
+}
+