|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T s
Length: 2199 (0x897)
Types: TextFile
Names: »screen.c«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Hangman1/screen.c«
/* screen.c
* hangman screen utilities from ogre with help from ritcv!jeb1265
* hangman by ritcv!jxs7451
*/
#define TRUE 1
#define FALSE 0
#include <sgtty.h>
struct sgttyb old_term, new_term;
short ospeed;
static char *cs_dwn,*BC,*UP,*cs_move;
static char *scn_eeol,*scn_eeos,*scn_dwn;
static backspace;
int putchar();
/*
* Set up the curses environment, and set terminal to CBREAK and NOECHO
* These last two are done for single character input with no echo.
* After this routine is called, a normal getchar() will
* fetch the next character on stdin.
*/
init_term()
{
static char bp[1024];
static char buffer[1024];
char *area = buffer;
char *getenv(),*tgetstr();
char *name;
int retcode;
name = getenv("TERM");
retcode = tgetent(bp, name);
switch(retcode) {
case -1:
printf("Unable to open termcap file.\n");
exit(1);
break;
case 0:
printf("No termcap entry for %s.\n",name);
exit(1);
break;
}
backspace = tgetflag("bs");
scn_eeos = tgetstr("cl",&area);
scn_eeol = tgetstr("ce",&area);
scn_dwn = tgetstr("sr",&area);
BC = tgetstr("bc",&area);
UP = tgetstr("up",&area);
cs_dwn = tgetstr("kd",&area);
cs_move = tgetstr("cm",&area);
gtty(0, &old_term);
gtty(0, &new_term);
new_term.sg_flags &= ~(ECHO | XTABS);
new_term.sg_flags |= CBREAK;
ospeed = new_term.sg_ospeed;
stty(0, &new_term);
}
/*
* Reset the terminal to normal mode. This MUST be called when
* you are all done, or boy, are you in trouble.
*/
reset_term()
{
stty(0, &old_term);
}
/*
* epage()
* Erase the terminal screen from current
* position to the end of the screen
*/
epage()
{
tputs(scn_eeos, 0, putchar);
}
/*
* erasel()
* If you give the arguments (0,0), current line is erased to
* end. Otherwise position to the given (i,j) and the erase
* the end of line.
*/
erasel(i,j)
int i,j;
{
if (i)
setcur(i,j);
tputs(scn_eeol, 0, putchar);
}
/*
* Move the cursor to (row,col). Notice the upper left is (1,1)
*/
setcur(row,col)
int row,col;
{
char *tgoto();
tputs(tgoto(cs_move,--col,--row), 0, putchar);
}