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