From eaf6e1e1a941b8e0b52abadcd8b55901d5cf5301 Mon Sep 17 00:00:00 2001 From: epochqwert Date: Fri, 16 Jan 2015 23:26:48 -0600 Subject: added tsize. used for showing terminal's size --- src/bin/tsize.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/bin/tsize.c diff --git a/src/bin/tsize.c b/src/bin/tsize.c new file mode 100644 index 0000000..475308d --- /dev/null +++ b/src/bin/tsize.c @@ -0,0 +1,36 @@ +#include +#include +#include + +void winhand(int sig) { + struct winsize ws; + ioctl(0,TIOCGWINSZ,&ws); + printf("%d x %d\n",ws.ws_col,ws.ws_row); +} + +#if 0 +struct winsize { + unsigned short ws_row; /* rows, in characters */ + unsigned short ws_col; /* columns, in characters */ + unsigned short ws_xpixel; /* horizontal size, pixels */ + unsigned short ws_ypixel; /* vertical size, pixels */ +}; + + + TIOCGWINSZ struct winsize *ws + Put the window size information associated with the terminal + in the winsize structure pointed to by ws. The window size + structure contains the number of rows and columns (and pixels + if appropriate) of the devices attached to the terminal. It + is set by user software and is the means by which most + full-screen oriented programs determine the screen size. The + winsize structure is defined in . +#endif + +int main(int argc,char *argv[]) { + winhand(SIGWINCH); + signal(SIGWINCH,winhand); + while(1) { + sleep(100); + } +} -- cgit v1.2.3