1: /* $Header: term.h,v 4.3.1.2 85/05/13 15:52:05 lwall Exp $
   2:  *
   3:  * $Log:	term.h,v $
   4:  * Revision 4.3.1.2  85/05/13  15:52:05  lwall
   5:  * Declared devtty on TERMIO system.
   6:  *
   7:  * Revision 4.3.1.1  85/05/10  11:41:24  lwall
   8:  * Branch for patches.
   9:  *
  10:  * Revision 4.3  85/05/01  11:51:36  lwall
  11:  * Baseline for release with 4.3bsd.
  12:  *
  13:  */
  14: 
  15: #ifdef PUSHBACK
  16: EXT char circlebuf[PUSHSIZE];
  17: EXT int nextin INIT(0);
  18: EXT int nextout INIT(0);
  19: #ifdef PENDING
  20: #ifdef FIONREAD
  21: EXT long iocount INIT(0);
  22: #ifndef lint
  23: #define input_pending() (nextin!=nextout || (ioctl(0, FIONREAD, &iocount),(int)iocount))
  24: #else
  25: #define input_pending() bizarre
  26: #endif lint
  27: #else FIONREAD
  28: int circfill();
  29: EXT int devtty INIT(0);
  30: #ifndef lint
  31: #define input_pending() (nextin!=nextout || circfill())
  32: #else
  33: #define input_pending() bizarre
  34: #endif lint
  35: #endif FIONREAD
  36: #else PENDING
  37: #ifndef lint
  38: #define input_pending() (nextin!=nextout)
  39: #else
  40: #define input_pending() bizarre
  41: #endif lint
  42: #endif PENDING
  43: #else PUSHBACK
  44: #ifdef PENDING
  45: #ifdef FIONREAD /* must have FIONREAD or O_NDELAY for input_pending() */
  46: #define read_tty(addr,size) read(0,addr,size)
  47: #ifndef lint
  48: #define input_pending() (ioctl(0, FIONREAD, &iocount),(int)iocount)
  49: #else
  50: #define input_pending() bizarre
  51: #endif lint
  52: EXT long iocount INIT(0);
  53: 
  54: #else FIONREAD
  55: 
  56: EXT int devtty INIT(0);
  57: EXT bool is_input INIT(FALSE);
  58: EXT char pending_ch INIT(0);
  59: #ifndef lint
  60: #define input_pending() (is_input || (is_input=read(devtty,&pending_ch,1)))
  61: #else
  62: #define input_pending() bizarre
  63: #endif lint
  64: #endif FIONREAD
  65: #else PENDING
  66: #define read_tty(addr,size) read(0,addr,size)
  67: #define input_pending() (FALSE)
  68: #endif PENDING
  69: #endif PUSHBACK
  70: 
  71: /* stuff wanted by terminal mode diddling routines */
  72: 
  73: #ifdef TERMIO
  74: EXT struct termio _tty, _oldtty;
  75: #else
  76: EXT struct sgttyb _tty;
  77: EXT int _res_flg INIT(0);
  78: #endif
  79: 
  80: EXT int _tty_ch INIT(2);
  81: EXT bool bizarre INIT(FALSE);           /* do we need to restore terminal? */
  82: 
  83: /* terminal mode diddling routines */
  84: 
  85: #ifdef TERMIO
  86: 
  87: #define crmode() ((bizarre=1),_tty.c_lflag &=~ICANON,_tty.c_cc[VMIN] = 1,ioctl(_tty_ch,TCSETAF,&_tty))
  88: #define nocrmode() ((bizarre=1),_tty.c_lflag |= ICANON,_tty.c_cc[VEOF] = CEOF,stty(_tty_ch,&_tty))
  89: #define echo()   ((bizarre=1),_tty.c_lflag |= ECHO, ioctl(_tty_ch, TCSETA, &_tty))
  90: #define noecho() ((bizarre=1),_tty.c_lflag &=~ECHO, ioctl(_tty_ch, TCSETA, &_tty))
  91: #define nl()     ((bizarre=1),_tty.c_iflag |= ICRNL,_tty.c_oflag |= ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
  92: #define nonl()   ((bizarre=1),_tty.c_iflag &=~ICRNL,_tty.c_oflag &=~ONLCR,ioctl(_tty_ch, TCSETAW, &_tty))
  93: #define savetty() (ioctl(_tty_ch, TCGETA, &_oldtty),ioctl(_tty_ch, TCGETA, &_tty))
  94: #define resetty() ((bizarre=0),ioctl(_tty_ch, TCSETAF, &_oldtty))
  95: #define unflush_output()
  96: 
  97: #else
  98: 
  99: #define raw()    ((bizarre=1),_tty.sg_flags|=RAW, stty(_tty_ch,&_tty))
 100: #define noraw()  ((bizarre=1),_tty.sg_flags&=~RAW,stty(_tty_ch,&_tty))
 101: #define crmode() ((bizarre=1),_tty.sg_flags |= CBREAK, stty(_tty_ch,&_tty))
 102: #define nocrmode() ((bizarre=1),_tty.sg_flags &= ~CBREAK,stty(_tty_ch,&_tty))
 103: #define echo()   ((bizarre=1),_tty.sg_flags |= ECHO, stty(_tty_ch, &_tty))
 104: #define noecho() ((bizarre=1),_tty.sg_flags &= ~ECHO, stty(_tty_ch, &_tty))
 105: #define nl()     ((bizarre=1),_tty.sg_flags |= CRMOD,stty(_tty_ch, &_tty))
 106: #define nonl()   ((bizarre=1),_tty.sg_flags &= ~CRMOD, stty(_tty_ch, &_tty))
 107: #define savetty() (gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags)
 108: #define resetty() ((bizarre=0),_tty.sg_flags = _res_flg, stty(_tty_ch, &_tty))
 109: #ifdef LFLUSHO
 110: #ifndef lint
 111: EXT int lflusho INIT(LFLUSHO);
 112: #else
 113: EXT long lflusho INIT(LFLUSHO);
 114: #endif lint
 115: #define unflush_output() (ioctl(_tty_ch,TIOCLBIC,&lflusho))
 116: #else
 117: #define unflush_output()
 118: #endif LFLUSHO
 119: #endif TERMIO
 120: 
 121: #ifdef TIOCSTI
 122: #ifdef lint
 123: #define forceme(c) ioctl(_tty_ch,TIOCSTI,Null(long*))   /* ghad! */
 124: #else
 125: #define forceme(c) ioctl(_tty_ch,TIOCSTI,c) /* pass character in " " */
 126: #endif lint
 127: #else
 128: #define forceme(c)
 129: #endif
 130: 
 131: /* termcap stuff */
 132: 
 133: /*
 134:  * NOTE: if you don't have termlib you'll either have to define these strings
 135:  *    and the tputs routine, or you'll have to redefine the macros below
 136:  */
 137: 
 138: #ifdef HAVETERMLIB
 139: EXT char *BC INIT(Nullch);      /* backspace character */
 140: EXT char *UP INIT(Nullch);      /* move cursor up one line */
 141: EXT char *CR INIT(Nullch);      /* get to left margin, somehow */
 142: EXT char *VB INIT(Nullch);      /* visible bell */
 143: EXT char *CL INIT(Nullch);      /* home and clear screen */
 144: EXT char *CE INIT(Nullch);      /* clear to end of line */
 145: #ifdef CLEAREOL
 146: EXT char *CM INIT(Nullch);      /* cursor motion -- PWP */
 147: EXT char *HO INIT(Nullch);      /* home cursor -- PWP */
 148: EXT char *CD INIT(Nullch);      /* clear to end of display -- PWP */
 149: #endif CLEAREOL
 150: EXT char *SO INIT(Nullch);      /* begin standout mode */
 151: EXT char *SE INIT(Nullch);      /* end standout mode */
 152: EXT int SG INIT(0);     /* blanks left by SO and SE */
 153: EXT char *US INIT(Nullch);      /* start underline mode */
 154: EXT char *UE INIT(Nullch);      /* end underline mode */
 155: EXT char *UC INIT(Nullch);      /* underline a character, if that's how it's done */
 156: EXT int UG INIT(0);     /* blanks left by US and UE */
 157: EXT bool AM INIT(FALSE);        /* does terminal have automatic margins? */
 158: EXT bool XN INIT(FALSE);        /* does it eat 1st newline after automatic wrap? */
 159: EXT char PC INIT(0);        /* pad character for use by tputs() */
 160: EXT short ospeed INIT(0);   /* terminal output speed, for use by tputs() */
 161: EXT int LINES INIT(0), COLS INIT(0);    /* size of screen */
 162: EXT int just_a_sec INIT(960);           /* 1 sec at current baud rate */
 163:                     /* (number of nulls) */
 164: 
 165: /* define a few handy macros */
 166: 
 167: #define backspace() tputs(BC,0,putchr) FLUSH
 168: #define clear() tputs(CL,LINES,putchr) FLUSH
 169: #define erase_eol() tputs(CE,1,putchr) FLUSH
 170: #ifdef CLEAREOL
 171: #define clear_rest() tputs(CD,LINES,putchr) FLUSH   /* PWP */
 172: #define maybe_eol() if(erase_screen&&can_home_clear)tputs(CE,1,putchr) FLUSH
 173: #endif CLEAREOL
 174: #define underline() tputs(US,1,putchr) FLUSH
 175: #define un_underline() tputs(UE,1,putchr) FLUSH
 176: #define underchar() tputs(UC,0,putchr) FLUSH
 177: #define standout() tputs(SO,1,putchr) FLUSH
 178: #define un_standout() tputs(SE,1,putchr) FLUSH
 179: #define up_line() tputs(UP,1,putchr) FLUSH
 180: #define carriage_return() tputs(CR,1,putchr) FLUSH
 181: #define dingaling() tputs(VB,1,putchr) FLUSH
 182: #else
 183:   ????????      /* up to you */
 184: #endif
 185: 
 186: EXT int page_line INIT(1);  /* line number for paging in print_line (origin 1) */
 187: 
 188: void    term_init();
 189: void    term_set();
 190: #ifdef PUSHBACK
 191: void    pushchar();
 192: void    mac_init();
 193: void    mac_line();
 194: void    show_macros();
 195: #endif
 196: char    putchr();   /* routine for tputs to call */
 197: bool    finish_command();
 198: void    eat_typeahead();
 199: void    settle_down();
 200: #ifndef read_tty
 201:     int     read_tty();
 202: #endif
 203: void    underprint();
 204: #ifdef NOFIREWORKS
 205:     void    no_sofire();
 206:     void    no_ulfire();
 207: #endif
 208: void    getcmd();
 209: int get_anything();
 210: void    in_char();
 211: int print_lines();
 212: void    page_init();
 213: void    pad();
 214: void    printcmd();
 215: void    rubout();
 216: void    reprint();
 217: #ifdef CLEAREOL
 218: void    home_cursor();
 219: #endif CLEAREOL

Defined variables

BC defined in line 139; used 5 times
CD defined in line 148; used 3 times
CE defined in line 144; used 4 times
CL defined in line 143; used 4 times
CM defined in line 146; used 4 times
COLS defined in line 161; used 9 times
CR defined in line 141; used 6 times
HO defined in line 147; used 4 times
LINES defined in line 161; used 19 times
PC defined in line 159; used 3 times
SE defined in line 151; used 4 times
SG defined in line 152; used 3 times
SO defined in line 150; used 3 times
UC defined in line 155; used 8 times
UE defined in line 154; used 3 times
UG defined in line 156; used 7 times
UP defined in line 140; used 8 times
US defined in line 153; used 6 times
VB defined in line 142; used 4 times
_oldtty defined in line 74; used 2 times
_res_flg defined in line 77; used 2 times
_tty defined in line 76; used 44 times
_tty_ch defined in line 80; used 23 times
circlebuf defined in line 16; used 3 times
devtty defined in line 56; used 5 times
iocount defined in line 52; used 4 times
  • in line 23(2), 48(2)
lflusho defined in line 113; used 1 times
nextin defined in line 17; used 11 times
nextout defined in line 18; used 14 times
ospeed defined in line 160; used 5 times
page_line defined in line 186; used 7 times
pending_ch defined in line 58; used 2 times

Defined macros

backspace defined in line 167; used 13 times
clear_rest defined in line 171; used 2 times
dingaling defined in line 181; used 3 times
echo defined in line 103; never used
erase_eol defined in line 169; used 6 times
forceme defined in line 128; used 1 times
maybe_eol defined in line 172; used 4 times
nl defined in line 105; never used
nocrmode defined in line 102; never used
nonl defined in line 106; never used
noraw defined in line 100; never used
raw defined in line 99; never used
read_tty defined in line 66; used 7 times
savetty defined in line 107; used 2 times
un_underline defined in line 175; used 6 times
underchar defined in line 176; used 6 times
underline defined in line 174; used 4 times
up_line defined in line 179; used 4 times

Usage of this include

Last modified: 1986-03-21
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2002
Valid CSS Valid XHTML 1.0 Strict