Actually limit the terminal width in the right place

This commit is contained in:
Peetz0r 2011-12-05 19:37:50 +01:00
parent 616b5189fa
commit 5cc51e5021

View File

@ -121,7 +121,7 @@ int digits(int val) {
* (^C) so that we can restore the cursor. * (^C) so that we can restore the cursor.
*/ */
void SIGINT_handler(int sig){ void SIGINT_handler(int sig){
printf("\033[?25h\033[0m"); printf("\\033[?25h\033[0m");
exit(0); exit(0);
} }
@ -366,12 +366,10 @@ int main(int argc, char ** argv) {
char * nterm = getenv("TERM"); char * nterm = getenv("TERM");
strcpy(term, nterm); strcpy(term, nterm);
/* Also get the number of columns, but not above 80 */ /* Also get the number of columns */
struct winsize w; struct winsize w;
ioctl(0, TIOCGWINSZ, &w); ioctl(0, TIOCGWINSZ, &w);
terminal_width = w.ws_col; terminal_width = w.ws_col;
if(terminal_width > 80) terminal_width = 80;
} }
/* Convert the entire terminal string to lower case */ /* Convert the entire terminal string to lower case */
@ -379,6 +377,9 @@ int main(int argc, char ** argv) {
term[k] = tolower(term[k]); term[k] = tolower(term[k]);
} }
/* We don't want terminals wider than 80 columns */
if(terminal_width > 80) terminal_width = 80;
/* Do our terminal detection */ /* Do our terminal detection */
if (strstr(term, "xterm")) { if (strstr(term, "xterm")) {
ttype = 1; /* 256-color, spaces */ ttype = 1; /* 256-color, spaces */