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