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