release 3.4, June 24, 1980
[unix-history] / usr / src / usr.bin / ex / ex_tty.h
CommitLineData
6fbec236
MH
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 */
28char tspace[256]; /* Space for capability strings */
29char *aoftspace; /* Address of tspace for relocation */
30
31char *AL; /* P* Add new blank line */
32char *BC; /* Back cursor */
33char *BT; /* P Back tab */
34char *CD; /* P* Clear to end of display */
35char *CE; /* P Clear to end of line */
36char *CL; /* P* Clear screen */
37char *CM; /* P Cursor motion */
d266c416 38char *xCR; /* P Carriage return */
6fbec236
MH
39char *DC; /* P* Delete character */
40char *DL; /* P* Delete line sequence */
41char *DM; /* Delete mode (enter) */
42char *DO; /* Down line sequence */
43char *ED; /* End delete mode */
44char *EI; /* End insert mode */
45char *F0,*F1,*F2,*F3,*F4,*F5,*F6,*F7,*F8,*F9;
46 /* Strings sent by various function keys */
47char *HO; /* Home cursor */
48char *IC; /* P Insert character */
49char *IM; /* Insert mode (give as ':im=:' if 'ic' */
50char *IP; /* P* Insert pad after char ins'd using IM+IE */
51char *KD; /* Keypad down arrow */
52char *KE; /* Keypad don't xmit */
53char *KH; /* Keypad home key */
54char *KL; /* Keypad left arrow */
55char *KR; /* Keypad right arrow */
56char *KS; /* Keypad start xmitting */
57char *KU; /* Keypad up arrow */
58char *LL; /* Quick to last line, column 0 */
59char *ND; /* Non-destructive space */
d266c416 60char *xNL; /* Line feed (new line) */
6fbec236
MH
61char PC; /* Pad character */
62char *SE; /* Standout end (may leave space) */
63char *SF; /* P Scroll forwards */
64char *SO; /* Stand out begin (may leave space) */
65char *SR; /* P Scroll backwards */
66char *TA; /* P Tab (other than ^I or with padding) */
67char *TE; /* Terminal end sequence */
68char *TI; /* Terminal initial sequence */
69char *UP; /* Upline */
70char *VB; /* Visible bell */
71char *VE; /* Visual end sequence */
72char *VS; /* Visual start sequence */
73bool AM; /* Automatic margins */
74bool BS; /* Backspace works */
75bool CA; /* Cursor addressible */
76bool DA; /* Display may be retained above */
77bool DB; /* Display may be retained below */
78bool EO; /* Can erase overstrikes with ' ' */
79bool GT; /* Gtty indicates tabs */
80bool HC; /* Hard copy terminal */
81bool HZ; /* Hazeltine ~ braindamage */
82bool IN; /* Insert-null blessing */
83bool MI; /* can move in insert mode */
84bool NC; /* No Cr - \r snds \r\n then eats \n (dm2500) */
d266c416 85bool NS; /* No scroll - linefeed at bottom won't scroll */
6fbec236
MH
86bool OS; /* Overstrike works */
87bool UL; /* Underlining works even though !os */
d266c416 88bool XB; /* Beehive (no escape key, simulate with f1) */
6fbec236
MH
89bool XN; /* A newline gets eaten after wrap (concept) */
90bool XT; /* Tabs are destructive */
d266c416 91bool XX; /* Tektronix 4025 insert line */
6fbec236
MH
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 */
98bool NONL; /* Terminal can't hack linefeeds doing a CR */
99bool UPPERCASE; /* Ick! */
100short LINES; /* Number of lines on screen */
101short COLUMNS;
102short OCOLUMNS; /* Save COLUMNS for a hack in open mode */
103
104short outcol; /* Where the cursor is */
105short outline;
106
107short destcol; /* Where the cursor should be */
108short destline;
109
d266c416
MH
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
6fbec236 140#endif
d266c416
MH
141
142ttymode normf; /* Restore tty flags to this (someday) */
143bool normtty; /* Have to restore normal mode from normf */
144
145ttymode ostart(), setty(), unixex();
6fbec236
MH
146
147short WBOT;
148short WECHO;
149
150short costCM;
151
887e3e0d
MH
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
6fbec236
MH
159struct maps {
160 char *cap; /* pressing button that sends this.. */
161 char *mapto; /* .. maps to this string */
162 char *descr; /* legible description of key */
163};
164struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */
887e3e0d 165struct maps immacs[MAXNOMACS]; /* for while in insert mode */
d266c416
MH
166struct maps abbrevs[MAXNOMACS]; /* for word abbreviations */
167int ldisc; /* line discipline for ucb tty driver */
6fbec236
MH
168char mapspace[MAXCHARMACS];
169char *msnext; /* next free location in mapspace */
d266c416
MH
170int maphopcnt; /* check for infinite mapping loops */
171bool anyabbrs; /* true if abbr or unabbr has been done */
172char ttynbuf[20]; /* result of ttyname() */
173int ttymesg; /* original mode of users tty */