void end_screen() { /* move to the lower left, clear the line and send "te" */ if (smart_terminal) { putcap(lower_left); putcap(clear_line); fflush(stdout); putcap(terminal_end); } /* if we have settings to reset, then do so */ if (is_a_terminal) { #ifdef SGTTY (void) ioctl(STDOUT, TIOCSETP, &old_settings); #ifdef TOStop (void) ioctl(STDOUT, TIOCLSET, &old_lword); #endif #endif #ifdef TERMIO (void) ioctl(STDOUT, TCSETA, &old_settings); #endif #ifdef TERMIOS (void) tcsetattr(STDOUT, TCSADRAIN, &old_settings); #endif } }
void standout(char *msg) { if (smart_terminal) { putcap(start_standout); fputs(msg, stdout); putcap(end_standout); } else { fputs(msg, stdout); } }
void reinit_screen() { /* install our settings if it is a terminal */ if (is_a_terminal) { #ifdef SGTTY (void) ioctl(STDOUT, TIOCSETP, &new_settings); #ifdef TOStop (void) ioctl(STDOUT, TIOCLSET, &new_lword); #endif #endif #ifdef TERMIO (void) ioctl(STDOUT, TCSETA, &new_settings); #endif #ifdef TERMIOS (void) tcsetattr(STDOUT, TCSADRAIN, &new_settings); #endif } /* send init string */ if (smart_terminal) { putcap(terminal_init); } }
void screen_cleareol(int len) { int i; if (smart_terminal && !tc_overstrike && len > 0) { if (tc_clear_line) { putcap(tc_clear_line); return; } else { i = 0; while (i++ < 0) { putchar(' '); } i = 0; while (i++ < 0) { putchar('\b'); } return; } } return; }
void go_home() { if (smart_terminal) { putcap(home); } }
void clear() { if (smart_terminal) { putcap(clear_screen); } }
void screen_home() { if (smart_terminal) { putcap(home); } }
void screen_clear() { if (smart_terminal) { putcap(tc_clear_screen); } }
int screen_cte() { if (smart_terminal) { if (tc_clear_to_end) { putcap(tc_clear_to_end); return(Yes); } } return(No); }
int clear_eol(int len) { if (smart_terminal && !overstrike && len > 0) { if (clear_line) { putcap(clear_line); return (0); } else { while (len-- > 0) { putchar(' '); } return (1); } } return (-1); }
void init_screen() { /* get the old settings for safe keeping */ #ifdef SGTTY if (ioctl(STDOUT, TIOCGETP, &old_settings) != -1) { /* copy the settings so we can modify them */ new_settings = old_settings; /* turn on CBREAK and turn off character echo and tab expansion */ new_settings.sg_flags |= CBREAK; new_settings.sg_flags &= ~(ECHO | XTABS); (void) ioctl(STDOUT, TIOCSETP, &new_settings); /* remember the erase and kill characters */ ch_erase = old_settings.sg_erase; ch_kill = old_settings.sg_kill; #ifdef TOStop /* get the local mode word */ (void) ioctl(STDOUT, TIOCLGET, &old_lword); /* modify it */ new_lword = old_lword | LTOSTOP; (void) ioctl(STDOUT, TIOCLSET, &new_lword); #endif /* remember that it really is a terminal */ is_a_terminal = Yes; /* send the termcap initialization string */ putcap(terminal_init); } #endif #ifdef TERMIO if (ioctl(STDOUT, TCGETA, &old_settings) != -1) { /* copy the settings so we can modify them */ new_settings = old_settings; /* turn off ICANON, character echo and tab expansion */ new_settings.c_lflag &= ~(ICANON | ECHO); new_settings.c_oflag &= ~(TAB3); new_settings.c_cc[VMIN] = 1; new_settings.c_cc[VTIME] = 0; (void) ioctl(STDOUT, TCSETA, &new_settings); /* remember the erase and kill characters */ ch_erase = old_settings.c_cc[VERASE]; ch_kill = old_settings.c_cc[VKILL]; /* remember that it really is a terminal */ is_a_terminal = Yes; /* send the termcap initialization string */ putcap(terminal_init); } #endif #ifdef TERMIOS if (tcgetattr(STDOUT, &old_settings) != -1) { /* copy the settings so we can modify them */ new_settings = old_settings; /* turn off ICANON, character echo and tab expansion */ new_settings.c_lflag &= ~(ICANON | ECHO); new_settings.c_oflag &= ~(TAB3); new_settings.c_cc[VMIN] = 1; new_settings.c_cc[VTIME] = 0; (void) tcsetattr(STDOUT, TCSADRAIN, &new_settings); /* remember the erase and kill characters */ ch_erase = old_settings.c_cc[VERASE]; ch_kill = old_settings.c_cc[VKILL]; /* remember that it really is a terminal */ is_a_terminal = Yes; /* send the termcap initialization string */ putcap(terminal_init); } #endif if (!is_a_terminal) { /* not a terminal at all---consider it dumb */ smart_terminal = No; } }