Advertisement
Advertisement
| 03.14.2008 at 09:11PM PDT, ID: 23243646 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: |
/*
** Terminal size parameters test program.
** cc -l readline -o col_test col_test.c
** Run this, resize window, run again.
**
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <readline/readline.h>
#include <readline/history.h>
main()
{
struct winsize win;
int temp;
printf("$COLUMNS=%s\n",getenv("COLUMNS"));
if( temp = ioctl(STDOUT_FILENO, TIOCGWINSZ, (void *)&win) ) {
printf("TIOCGWINSZ failed %d\n",temp);
} else {
printf("TIOCGWINSZ win.ws_col=%d\n",win.ws_col);
}
readline("What OS are you running this on? ");
readline("What OS are you typing on? ");
readline("What terminal emulator are you using? ");
printf("$COLUMNS=%s\n",getenv("COLUMNS"));
if( temp = ioctl(STDOUT_FILENO, TIOCGWINSZ, (void *)&win) ) {
printf("TIOCGWINSZ failed %d\n",temp);
} else {
printf("TIOCGWINSZ win.ws_col=%d\n",win.ws_col);
}
}
|