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