version 1.4, 1997/11/12 04:40:51 |
version 1.5, 1997/11/12 06:28:26 |
|
|
*sc_deinit; /* Exit terminal de-initialization */ |
*sc_deinit; /* Exit terminal de-initialization */ |
|
|
static int init_done = 0; |
static int init_done = 0; |
|
static int tty_fd = -1; |
|
|
public int auto_wrap; /* Terminal does \r\n when write past margin */ |
public int auto_wrap; /* Terminal does \r\n when write past margin */ |
public int ignaw; /* Terminal ignores \n immediately after wrap */ |
public int ignaw; /* Terminal ignores \n immediately after wrap */ |
|
|
|
|
if (on == curr_on) |
if (on == curr_on) |
return; |
return; |
|
|
|
if (tty_fd == -1 && (tty_fd = open("/dev/tty", O_RDWR)) < 0) |
|
tty_fd = 2; |
|
|
#if OS2 |
#if OS2 |
signal(SIGINT, SIG_IGN); |
signal(SIGINT, SIG_IGN); |
erase_char = '\b'; |
erase_char = '\b'; |
|
|
/* |
/* |
* Get terminal modes. |
* Get terminal modes. |
*/ |
*/ |
tcgetattr(2, &s); |
if (tcgetattr(tty_fd, &s) == -1) |
|
return; |
|
|
/* |
/* |
* Save modes and set certain variables dependent on modes. |
* Save modes and set certain variables dependent on modes. |
|
|
*/ |
*/ |
s = save_term; |
s = save_term; |
} |
} |
tcsetattr(2, TCSANOW, &s); |
if (tcsetattr(tty_fd, TCSANOW, &s) == -1) |
|
return; |
} |
} |
#else |
#else |
#ifdef TCGETA |
#ifdef TCGETA |
|
|
/* |
/* |
* Get terminal modes. |
* Get terminal modes. |
*/ |
*/ |
ioctl(2, TCGETA, &s); |
ioctl(tty_fd, TCGETA, &s); |
|
|
/* |
/* |
* Save modes and set certain variables dependent on modes. |
* Save modes and set certain variables dependent on modes. |
|
|
*/ |
*/ |
s = save_term; |
s = save_term; |
} |
} |
ioctl(2, TCSETAW, &s); |
ioctl(tty_fd, TCSETAW, &s); |
} |
} |
#else |
#else |
{ |
{ |
|
|
/* |
/* |
* Get terminal modes. |
* Get terminal modes. |
*/ |
*/ |
ioctl(2, TIOCGETP, &s); |
ioctl(tty_fd, TIOCGETP, &s); |
|
|
/* |
/* |
* Save modes and set certain variables dependent on modes. |
* Save modes and set certain variables dependent on modes. |
|
|
*/ |
*/ |
s = save_term; |
s = save_term; |
} |
} |
ioctl(2, TIOCSETN, &s); |
ioctl(tty_fd, TIOCSETN, &s); |
} |
} |
#endif |
#endif |
#endif |
#endif |
|
|
#endif |
#endif |
#endif |
#endif |
|
|
|
if (tty_fd == -1 && (tty_fd = open("/dev/tty", O_RDWR)) < 0) |
|
tty_fd = 2; |
|
|
#ifdef TIOCGWINSZ |
#ifdef TIOCGWINSZ |
if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_row > 0) |
if (ioctl(tty_fd, TIOCGWINSZ, &w) == 0 && w.ws_row > 0) |
sc_height = w.ws_row; |
sc_height = w.ws_row; |
else |
else |
#else |
#else |
#ifdef WIOCGETD |
#ifdef WIOCGETD |
if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_height > 0) |
if (ioctl(tty_fd, WIOCGETD, &w) == 0 && w.uw_height > 0) |
sc_height = w.uw_height/w.uw_vs; |
sc_height = w.uw_height/w.uw_vs; |
else |
else |
#endif |
#endif |
|
|
sc_height = 24; |
sc_height = 24; |
|
|
#ifdef TIOCGWINSZ |
#ifdef TIOCGWINSZ |
if (ioctl(2, TIOCGWINSZ, &w) == 0 && w.ws_col > 0) |
if (ioctl(tty_fd, TIOCGWINSZ, &w) == 0 && w.ws_col > 0) |
sc_width = w.ws_col; |
sc_width = w.ws_col; |
else |
else |
#ifdef WIOCGETD |
#ifdef WIOCGETD |
if (ioctl(2, WIOCGETD, &w) == 0 && w.uw_width > 0) |
if (ioctl(tty_fd, WIOCGETD, &w) == 0 && w.uw_width > 0) |
sc_width = w.uw_width/w.uw_hs; |
sc_width = w.uw_width/w.uw_hs; |
else |
else |
#endif |
#endif |