aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorepochqwert <epoch@53flpnlls43fcguy.onion>2015-01-16 23:26:48 -0600
committerepochqwert <epoch@53flpnlls43fcguy.onion>2015-01-16 23:26:48 -0600
commiteaf6e1e1a941b8e0b52abadcd8b55901d5cf5301 (patch)
tree02f71576164fdcf80b21bf131f246cfca6b3ca49 /src
parent74406e6eee2f69e8861315071b5be38571747c11 (diff)
downloadmisc-eaf6e1e1a941b8e0b52abadcd8b55901d5cf5301.tar.gz
misc-eaf6e1e1a941b8e0b52abadcd8b55901d5cf5301.zip
added tsize. used for showing terminal's size
Diffstat (limited to 'src')
-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);
+ }
+}