toaruos/apps/term-size.c

22 lines
690 B
C
Raw Normal View History

2018-08-15 04:07:33 +03:00
/* vim: tabstop=4 shiftwidth=4 noexpandtab
* This file is part of ToaruOS and is released under the terms
* of the NCSA / University of Illinois License - see LICENSE.md
2018-07-23 14:01:23 +03:00
* Copyright (C) 2013 K. Lange
2018-08-15 04:07:33 +03:00
*
* term-size - Print the size of the tty
*
* This is mostly redundant with ttysize, and should probably
* be replaced with setting COLUMNS and LINES in the shell,
* like bash does, but it's left here for historical reasons
*/
#include <stdio.h>
#include <sys/ioctl.h>
#include <termios.h>
int main(int argc, char * argv[]) {
struct winsize w;
ioctl(0, TIOCGWINSZ, &w);
printf("Terminal is %dx%d (%d px x %d px)\n", w.ws_col, w.ws_row, w.ws_xpixel, w.ws_ypixel);
return 0;
}