summaryrefslogtreecommitdiff
path: root/Userland/tst.cpp
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-29 03:45:23 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-29 03:45:23 +0100
commitac7a60225e9c2024a167d6f3f440780cf7af304a (patch)
tree0c855212e58a066e6ffcd571f2892dd8837af0dc /Userland/tst.cpp
parentf5a83c4d8aa3971c53234503484d440fb9757bc1 (diff)
downloadserenity-ac7a60225e9c2024a167d6f3f440780cf7af304a.zip
Add TIOCGWINSZ ioctl so userland can determine terminal geometry.
(Don't) use this to implement short-form output in ls. I'm too tired to make a nice column formatting algorithm. I just wanted something concise when I type "ls".
Diffstat (limited to 'Userland/tst.cpp')
-rw-r--r--Userland/tst.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/Userland/tst.cpp b/Userland/tst.cpp
index 9659a20aab..14463f691f 100644
--- a/Userland/tst.cpp
+++ b/Userland/tst.cpp
@@ -1,9 +1,15 @@
-#include <LibC/stdio.h>
+#include <stdio.h>
+#include <sys/ioctl.h>
int main(int argc, char** argv)
{
(void) argc;
(void) argv;
+
+ struct winsize ws;
+ ioctl(0, TIOCGWINSZ, &ws);
+ printf("Terminal is %ux%u\n", ws.ws_col, ws.ws_row);
+
printf("Counting to 100000: \033[s");
for (unsigned i = 0; i <= 100000; ++i) {
printf("\033[u\033[s%u", i);