490 |
static void set_term (void) |
static void set_term (void) |
491 |
{ |
{ |
492 |
if (tms_set) |
if (tms_set) |
493 |
tcsetattr (0, TCSANOW, &tms); |
tcsetattr (fileno (stdin), TCSANOW, &tms); |
494 |
} |
} |
495 |
|
|
496 |
static void get_term (void) |
static void get_term (void) |
497 |
{ |
{ |
498 |
if (isatty (1)) { |
if (isatty (fileno (stdout))) { |
499 |
if (debug) |
if (debug) |
500 |
fprintf(stderr, "is a tty\n"); |
fprintf(stderr, "is a tty\n"); |
501 |
tcgetattr (0, &tms); |
tcgetattr (fileno (stdin), &tms); |
502 |
if (!tms_set++) |
if (!tms_set++) |
503 |
atexit (set_term); |
atexit (set_term); |
504 |
} |
} |
533 |
} |
} |
534 |
|
|
535 |
#ifdef TIOCGWINSZ |
#ifdef TIOCGWINSZ |
536 |
if (isatty(0) && isatty(1)) { /* Jon Tombs */ |
/* Jon Tombs */ |
537 |
|
if (isatty (fileno (stdin)) && isatty (fileno (stdout))) { |
538 |
struct winsize wsz; |
struct winsize wsz; |
539 |
|
|
540 |
if (ioctl (0, TIOCGWINSZ, &wsz)) |
if (ioctl (fileno (stdin), TIOCGWINSZ, &wsz)) |
541 |
perror ("TIOCGWINSZ failed\n"); |
perror ("TIOCGWINSZ failed\n"); |
542 |
else if (wsz.ws_col) { |
else if (wsz.ws_col) { |
543 |
line_length = wsz.ws_col; |
line_length = wsz.ws_col; |