summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/bin/tsize.c36
1 files changed, 36 insertions, 0 deletions
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 <stdio.h>
+#include <signal.h>
+#include <sys/ttycom.h>
+
+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 <sys/ioctl.h>.
+#endif
+
+int main(int argc,char *argv[]) {
+ winhand(SIGWINCH);
+ signal(SIGWINCH,winhand);
+ while(1) {
+ sleep(100);
+ }
+}