Changeset View
Changeset View
Standalone View
Standalone View
screen.c
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | |||||
# endif | # endif | ||||
# endif | # endif | ||||
#endif | #endif | ||||
#include "screen.h" | #include "screen.h" | ||||
#include "boolean.h" | #include "boolean.h" | ||||
extern char *myname; | extern char *myname; | ||||
int putstdout(); | |||||
int overstrike; | int overstrike; | ||||
int screen_length; | int screen_length; | ||||
int screen_width; | int screen_width; | ||||
char ch_erase; | char ch_erase; | ||||
char ch_kill; | char ch_kill; | ||||
char smart_terminal; | char smart_terminal; | ||||
char PC; | char PC; | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | |||||
#ifdef TERMIOS | #ifdef TERMIOS | ||||
if (tcgetattr(STDOUT, &old_settings) == -1) | if (tcgetattr(STDOUT, &old_settings) == -1) | ||||
{ | { | ||||
smart_terminal = No; | smart_terminal = No; | ||||
} | } | ||||
#endif | #endif | ||||
} | } | ||||
void | |||||
init_screen() | init_screen() | ||||
{ | { | ||||
/* get the old settings for safe keeping */ | /* get the old settings for safe keeping */ | ||||
#ifdef SGTTY | #ifdef SGTTY | ||||
if (ioctl(STDOUT, TIOCGETP, &old_settings) != -1) | if (ioctl(STDOUT, TIOCGETP, &old_settings) != -1) | ||||
{ | { | ||||
/* copy the settings so we can modify them */ | /* copy the settings so we can modify them */ | ||||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Lines | #endif | ||||
if (!is_a_terminal) | if (!is_a_terminal) | ||||
{ | { | ||||
/* not a terminal at all---consider it dumb */ | /* not a terminal at all---consider it dumb */ | ||||
smart_terminal = No; | smart_terminal = No; | ||||
} | } | ||||
} | } | ||||
void | |||||
end_screen() | end_screen() | ||||
{ | { | ||||
/* move to the lower left, clear the line and send "te" */ | /* move to the lower left, clear the line and send "te" */ | ||||
if (smart_terminal) | if (smart_terminal) | ||||
{ | { | ||||
putcap(lower_left); | putcap(lower_left); | ||||
putcap(clear_line); | putcap(clear_line); | ||||
Show All 14 Lines | #ifdef TERMIO | ||||
(void) ioctl(STDOUT, TCSETA, &old_settings); | (void) ioctl(STDOUT, TCSETA, &old_settings); | ||||
#endif | #endif | ||||
#ifdef TERMIOS | #ifdef TERMIOS | ||||
(void) tcsetattr(STDOUT, TCSADRAIN, &old_settings); | (void) tcsetattr(STDOUT, TCSADRAIN, &old_settings); | ||||
#endif | #endif | ||||
} | } | ||||
} | } | ||||
void | |||||
reinit_screen() | reinit_screen() | ||||
{ | { | ||||
/* install our settings if it is a terminal */ | /* install our settings if it is a terminal */ | ||||
if (is_a_terminal) | if (is_a_terminal) | ||||
{ | { | ||||
#ifdef SGTTY | #ifdef SGTTY | ||||
(void) ioctl(STDOUT, TIOCSETP, &new_settings); | (void) ioctl(STDOUT, TIOCSETP, &new_settings); | ||||
Show All 11 Lines | #endif | ||||
/* send init string */ | /* send init string */ | ||||
if (smart_terminal) | if (smart_terminal) | ||||
{ | { | ||||
putcap(terminal_init); | putcap(terminal_init); | ||||
} | } | ||||
} | } | ||||
void | |||||
get_screensize() | get_screensize() | ||||
{ | { | ||||
#ifdef TIOCGWINSZ | #ifdef TIOCGWINSZ | ||||
struct winsize ws; | struct winsize ws; | ||||
Show All 29 Lines | |||||
#endif /* TIOCGSIZE */ | #endif /* TIOCGSIZE */ | ||||
#endif /* TIOCGWINSZ */ | #endif /* TIOCGWINSZ */ | ||||
(void) strncpy(lower_left, tgoto(cursor_motion, 0, screen_length - 1), | (void) strncpy(lower_left, tgoto(cursor_motion, 0, screen_length - 1), | ||||
sizeof(lower_left) - 1); | sizeof(lower_left) - 1); | ||||
lower_left[sizeof(lower_left) - 1] = '\0'; | lower_left[sizeof(lower_left) - 1] = '\0'; | ||||
} | } | ||||
void | |||||
standout(msg) | standout(msg) | ||||
char *msg; | char *msg; | ||||
{ | { | ||||
if (smart_terminal) | if (smart_terminal) | ||||
{ | { | ||||
putcap(start_standout); | putcap(start_standout); | ||||
fputs(msg, stdout); | fputs(msg, stdout); | ||||
putcap(end_standout); | putcap(end_standout); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
fputs(msg, stdout); | fputs(msg, stdout); | ||||
} | } | ||||
} | } | ||||
void | |||||
clear() | clear() | ||||
{ | { | ||||
if (smart_terminal) | if (smart_terminal) | ||||
{ | { | ||||
putcap(clear_screen); | putcap(clear_screen); | ||||
} | } | ||||
} | } | ||||
int | |||||
clear_eol(len) | clear_eol(len) | ||||
int len; | int len; | ||||
{ | { | ||||
if (smart_terminal && !overstrike && len > 0) | if (smart_terminal && !overstrike && len > 0) | ||||
{ | { | ||||
if (clear_line) | if (clear_line) | ||||
{ | { | ||||
putcap(clear_line); | putcap(clear_line); | ||||
return(0); | return(0); | ||||
} | } | ||||
else | else | ||||
{ | { | ||||
while (len-- > 0) | while (len-- > 0) | ||||
{ | { | ||||
putchar(' '); | putchar(' '); | ||||
} | } | ||||
return(1); | return(1); | ||||
} | } | ||||
} | } | ||||
return(-1); | return(-1); | ||||
} | } | ||||
void | |||||
go_home() | go_home() | ||||
{ | { | ||||
if (smart_terminal) | if (smart_terminal) | ||||
{ | { | ||||
putcap(home); | putcap(home); | ||||
} | } | ||||
} | } | ||||
/* This has to be defined as a subroutine for tputs (instead of a macro) */ | /* This has to be defined as a subroutine for tputs (instead of a macro) */ | ||||
void | |||||
putstdout(ch) | putstdout(ch) | ||||
char ch; | char ch; | ||||
{ | { | ||||
putchar(ch); | putchar(ch); | ||||
} | } | ||||