1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:07:35 +00:00

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".
This commit is contained in:
Andreas Kling 2018-11-29 03:45:23 +01:00
parent f5a83c4d8a
commit ac7a60225e
11 changed files with 208 additions and 63 deletions

View file

@ -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);