diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-29 03:45:23 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-29 03:45:23 +0100 |
commit | ac7a60225e9c2024a167d6f3f440780cf7af304a (patch) | |
tree | 0c855212e58a066e6ffcd571f2892dd8837af0dc /Userland/tst.cpp | |
parent | f5a83c4d8aa3971c53234503484d440fb9757bc1 (diff) | |
download | serenity-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.cpp | 8 |
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); |