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