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