1 /* Copyright (c) 1981 Regents of the University of California */ 2 /* sccs id: @(#)ex_tty.h 7.1 07/08/81 */ 3 /* 4 * Capabilities from termcap 5 * 6 * The description of terminals is a difficult business, and we only 7 * attempt to summarize the capabilities here; for a full description 8 * see the paper describing termcap. 9 * 10 * Capabilities from termcap are of three kinds - string valued options, 11 * numeric valued options, and boolean options. The string valued options 12 * are the most complicated, since they may include padding information, 13 * which we describe now. 14 * 15 * Intelligent terminals often require padding on intelligent operations 16 * at high (and sometimes even low) speed. This is specified by 17 * a number before the string in the capability, and has meaning for the 18 * capabilities which have a P at the front of their comment. 19 * This normally is a number of milliseconds to pad the operation. 20 * In the current system which has no true programmible delays, we 21 * do this by sending a sequence of pad characters (normally nulls, but 22 * specifiable as "pc"). In some cases, the pad is better computed 23 * as some number of milliseconds times the number of affected lines 24 * (to bottom of screen usually, except when terminals have insert modes 25 * which will shift several lines.) This is specified as '12*' e.g. 26 * before the capability to say 12 milliseconds per affected whatever 27 * (currently always line). Capabilities where this makes sense say P*. 28 */ 29 extern char tspace[256]; /* Space for capability strings */ 30 extern char *aoftspace; /* Address of tspace for relocation */ 31 32 extern char *AL; /* P* Add new blank line */ 33 extern char *BC; /* Back cursor */ 34 extern char *BT; /* P Back tab */ 35 extern char *CD; /* P* Clear to end of display */ 36 extern char *CE; /* P Clear to end of line */ 37 extern char *CL; /* P* Clear screen */ 38 extern char *CM; /* P Cursor motion */ 39 extern char *xCR; /* P Carriage return */ 40 extern char *DC; /* P* Delete character */ 41 extern char *DL; /* P* Delete line sequence */ 42 extern char *DM; /* Delete mode (enter) */ 43 extern char *DO; /* Down line sequence */ 44 extern char *ED; /* End delete mode */ 45 extern char *EI; /* End insert mode */ 46 extern char *F0,*F1,*F2,*F3,*F4,*F5,*F6,*F7,*F8,*F9; 47 /* Strings sent by various function keys */ 48 extern char *HO; /* Home cursor */ 49 extern char *IC; /* P Insert character */ 50 extern char *IM; /* Insert mode (give as ':im=:' if 'ic' */ 51 extern char *IP; /* P* Insert pad after char ins'd using IM+IE */ 52 extern char *KD; /* Keypad down arrow */ 53 extern char *KE; /* Keypad don't xmit */ 54 extern char *KH; /* Keypad home key */ 55 extern char *KL; /* Keypad left arrow */ 56 extern char *KR; /* Keypad right arrow */ 57 extern char *KS; /* Keypad start xmitting */ 58 extern char *KU; /* Keypad up arrow */ 59 extern char *LL; /* Quick to last line, column 0 */ 60 extern char *ND; /* Non-destructive space */ 61 extern char *xNL; /* Line feed (new line) */ 62 extern char PC; /* Pad character */ 63 extern char *SE; /* Standout end (may leave space) */ 64 extern char *SF; /* P Scroll forwards */ 65 extern char *SO; /* Stand out begin (may leave space) */ 66 extern char *SR; /* P Scroll backwards */ 67 extern char *TA; /* P Tab (other than ^I or with padding) */ 68 extern char *TE; /* Terminal end sequence */ 69 extern char *TI; /* Terminal initial sequence */ 70 extern char *UP; /* Upline */ 71 extern char *VB; /* Visible bell */ 72 extern char *VE; /* Visual end sequence */ 73 extern char *VS; /* Visual start sequence */ 74 extern bool AM; /* Automatic margins */ 75 extern bool BS; /* Backspace works */ 76 extern bool CA; /* Cursor addressible */ 77 extern bool DA; /* Display may be retained above */ 78 extern bool DB; /* Display may be retained below */ 79 extern bool EO; /* Can erase overstrikes with ' ' */ 80 extern bool GT; /* Gtty indicates tabs */ 81 extern bool HC; /* Hard copy terminal */ 82 extern bool HZ; /* Hazeltine ~ braindamage */ 83 extern bool IN; /* Insert-null blessing */ 84 extern bool MI; /* can move in insert mode */ 85 extern bool NC; /* No Cr - \r snds \r\n then eats \n (dm2500) */ 86 extern bool NS; /* No scroll - linefeed at bottom won't scroll */ 87 extern bool OS; /* Overstrike works */ 88 extern bool UL; /* Underlining works even though !os */ 89 extern bool XB; /* Beehive (no escape key, simulate with f1) */ 90 extern bool XN; /* A newline gets eaten after wrap (concept) */ 91 extern bool XT; /* Tabs are destructive */ 92 bool XV; /* VT100 - run AL and DL through tgoto */ 93 extern bool XX; /* Tektronix 4025 insert line */ 94 /* X? is reserved for severely nauseous glitches */ 95 /* If there are enough of these we may need bit masks! */ 96 97 /* 98 * From the tty modes... 99 */ 100 extern bool NONL; /* Terminal can't hack linefeeds doing a CR */ 101 extern bool UPPERCASE; /* Ick! */ 102 extern short LINES; /* Number of lines on screen */ 103 extern short COLUMNS; 104 extern short OCOLUMNS; /* Save COLUMNS for a hack in open mode */ 105 106 extern short outcol; /* Where the cursor is */ 107 extern short outline; 108 109 extern short destcol; /* Where the cursor should be */ 110 extern short destline; 111 112 /* 113 * There are several kinds of tty drivers to contend with. These include: 114 * (1) V6: no CBREAK, no ioctl. (Include PWB V1 here). 115 * (2) V7 research: has CBREAK, has ioctl, and has the tchars (TIOCSETC) 116 * business to change start, stop, etc. chars. 117 * (3) USG V2: Basically like V6 but RAW mode is like V7 RAW. 118 * (We treat it as V6.) 119 * (4) USG V3: equivalent to V7 but totally incompatible. 120 * (5) Berkeley: has ltchars in addition to all of V7. 121 * 122 * The following attempts to decide what we are on, and declare 123 * some variables in the appropriate format. The wierd looking one (ttymode) 124 * is the thing we pass to sTTY and family to turn "RAW" mode on or off 125 * when we go into or out of visual mode. In V7/V6 it's just the flags word 126 * to stty. In USG V3 it's the whole tty structure. 127 */ 128 #ifdef USG3TTY /* USG V3 */ 129 extern struct termio tty; /* Use this one structure to change modes */ 130 typedef struct termio ttymode; /* Mode to contain tty flags */ 131 132 #else /* All others */ 133 extern struct sgttyb tty; /* Always stty/gtty using this one structure */ 134 typedef int ttymode; /* Mode to contain tty flags */ 135 # ifdef TIOCSETC /* V7 */ 136 extern struct tchars ottyc, nttyc; /* For V7 character masking */ 137 # endif 138 # ifdef TIOCLGET /* Berkeley */ 139 extern struct ltchars olttyc, nlttyc; /* More of tchars style stuff */ 140 # endif 141 142 #endif 143 144 extern ttymode normf; /* Restore tty flags to this (someday) */ 145 extern bool normtty; /* Have to restore normal mode from normf */ 146 147 ttymode ostart(), setty(), unixex(); 148 149 extern short WBOT; 150 extern short WECHO; 151 152 extern short costCM; /* # chars to output a typical CM, with padding etc. */ 153 extern short costSR; /* likewise */ 154 extern short costAL; 155 156 #ifdef VMUNIX 157 # define MAXNOMACS 128 /* max number of macros of each kind */ 158 # define MAXCHARMACS 2048 /* max # of chars total in macros */ 159 #else 160 # define MAXNOMACS 32 /* max number of macros of each kind */ 161 # define MAXCHARMACS 512 /* max # of chars total in macros */ 162 #endif 163 struct maps { 164 char *cap; /* pressing button that sends this.. */ 165 char *mapto; /* .. maps to this string */ 166 char *descr; /* legible description of key */ 167 }; 168 extern struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */ 169 extern struct maps immacs[MAXNOMACS]; /* for while in insert mode */ 170 extern struct maps abbrevs[MAXNOMACS]; /* for word abbreviations */ 171 extern int ldisc; /* line discipline for ucb tty driver */ 172 extern char mapspace[MAXCHARMACS]; 173 extern char *msnext; /* next free location in mapspace */ 174 extern int maphopcnt; /* check for infinite mapping loops */ 175 extern bool anyabbrs; /* true if abbr or unabbr has been done */ 176 extern char ttynbuf[20]; /* result of ttyname() */ 177 extern int ttymesg; /* original mode of users tty */ 178