3 /* This file contains functions which simulate the termcap functions.
5 * It doesn't access a "termcap" file. Instead, it uses an initialized array
6 * of strings to store the entries. Any string that doesn't start with a ':'
7 * is taken to be the name of a type of terminal. Any string that does start
8 * with a ':' is interpretted as the list of fields describing all of the
9 * terminal types that precede it.
11 * Note: since these are C strings, you can't use special sequences like
12 * ^M or \E in the fields; your C compiler won't understand them. Also,
13 * at run time there is no way to tell the difference between ':' and '\072'
14 * so I sure hope your terminal definition doesn't require a ':' character.
16 * getenv(TERM) on VMS checks the SET TERM device setting. To implement
17 * non-standard terminals set the logical ELVIS_TERM in VMS. (jdc)
19 * Other possible terminal types are...
20 * TERM_WYSE925 - "wyse925", a Wyse 50 terminal emulating Televideo 925
21 * ... or you could set $TERMCAP to the terminal's description string, which
22 * $TERM set up to match it.
24 * Note that you can include several terminal types at the same time. Elvis
25 * chooses which entry to use at runtime, based primarily on the value of $TERM.
30 extern char *getenv();
32 /* decide which terminal descriptions should *always* be included. */
48 # define TERM_AMIGA /* Internal Amiga termcap entry */
49 /* # define TERM_VT52 /* The rest of these are here for those */
50 # define TERM_VT100 /* people who want to use elvis over an */
51 /* # define TERM_NANSI /* AUX: port (serial.device). */
52 /* # define TERM_DOSANSI /* Take out all but AMIGA to save memory. */
53 /* # define TERM_MINIX /* Vanilla ANSI? */
54 /* # define TERM_925 /* Hang a terminal off your Amiga */
62 # define TERM_COHERENT
69 static char *termcap
[] =
75 /* Amiga termcap modified from version 1.3 by Kent Polk */
76 ":co#80:li#24:am:bs:bw:xn:\
77 :AL=\233%dL:DC=\233%dP:DL=\233%dM:DO=\233%dB:\
78 :LE=\233%dD:RI=\233%dC:SF=\233%dS:SR=\233%dT:UP=\233%dA:IC=\233%d@:\
79 :ae=\2330m:al=\233L:as=\2333m:bl=\007:bt=\233Z:cd=\233J:\
80 :ce=\233K:cl=\013:cm=\233%i%d;%dH:dc=\233P:dl=\233M:do=\233B:\
81 :kb=^H:ho=\233H:ic=\233@:is=\23320l:\
82 :mb=\2337;2m:md=\2331m:me=\2330m:mh=\2332m:mk=\2338m:mr=\2337m:nd=\233C:\
83 :rs=\033c:se=\2330m:sf=\233S:so=\2337m:sb=\233T:sr=\233T:ue=\23323m:\
84 :up=\233A:us=\2334m:vb=\007:ve=\233\040p:vi=\2330\040p:\
85 :k1=\2330~:k2=\2331~:k3=\2332~:k4=\2333~:k5=\2334~:\
86 :k6=\2335~:k7=\2336~:k8=\2337~:k9=\2338~:k0=\2339~:\
87 :s1=\23310~:s2=\23311~:s3=\23312~:s4=\23313~:s5=\23314~:\
88 :s6=\23315~:s7=\23316~:s8=\23317~:s9=\23318~:s0=\23319~:\
89 :kd=\233B:kl=\233D:kn#10:kr=\233C:ku=\233A:le=\233D:\
90 :kP=\233T:kN=\233S:kh=\233\040A:kH=\233\040@:",
98 ":al=\033[L:dl=\033[M:am:bs:ce=\033[K:cl=\033[2J:\
99 :cm=\033[%i%d;%dH:co#80:do=\033[B:\
100 :k1=#;:k2=#<:k3=#=:k4=#>:k5=#?:k6=#@:k7=#A:k8=#B:k9=#C:k0=#D:\
101 :s1=#T:s2=#U:s3=#V:s4=#W:s5=#X:s6=#Y:s7=#Z:s8=#[:s9=#\\:s0=#]:\
102 :c1=#^:c2=#_:c3=#`:c4=#a:c5=#b:c6=#c:c7=#d:c8=#e:c9=#f:c0=#g:\
103 :a1=#h:a2=#i:a3=#j:a4=#k:a5=#l:a6=#m:a7=#n:a8=#o:a9=#p:a0=#q:\
104 :kd=#P:kh=#G:kH=#O:kI=#R:kl=#K:kN=#Q:kP=#I:kr=#M:ku=#H:\
105 :li#25:md=\033[1m:me=\033[m:nd=\033[C:se=\033[m:so=\033[7m:\
106 :ue=\033[m:up=\033[A:us=\033[4m:",
114 ":am:bs:ce=\033[K:cl=\033[2J:\
115 :cm=\033[%i%d;%dH:co#80:do=\033[B:\
116 :k1=#;:k2=#<:k3=#=:k4=#>:k5=#?:k6=#@:k7=#A:k8=#B:k9=#C:k0=#D:\
117 :s1=#T:s2=#U:s3=#V:s4=#W:s5=#X:s6=#Y:s7=#Z:s8=#[:s9=#\\:s0=#]:\
118 :c1=#^:c2=#_:c3=#`:c4=#a:c5=#b:c6=#c:c7=#d:c8=#e:c9=#f:c0=#g:\
119 :a1=#h:a2=#i:a3=#j:a4=#k:a5=#l:a6=#m:a7=#n:a8=#o:a9=#p:a0=#q:\
120 :kd=#P:kh=#G:kH=#O:kI=#R:kl=#K:kN=#Q:kP=#I:kr=#M:ku=#H:\
121 :li#25:md=\033[1m:me=\033[m:nd=\033[C:se=\033[m:so=\033[7m:\
122 :ue=\033[m:up=\033[A:us=\033[4m:",
128 ":al=\033[L:dl=\033[M:am:bs:ce=\033[K:cl=\033[2J:\
129 :cm=\033[%i%d;%dH:co#80:do=\033[B:kd=\033[B:kl=\033[D:\
130 :kr=\033[C:ku=\033[A:kP=\033[5~:kN=\033[6~:kI=\033[2~:\
131 :li#24:md=\033[1m:me=\033[m:nd=\033[C:se=\033[m:so=\033[7m:\
132 :ue=\033[m:up=\033[A:us=\033[4m:xn:",
141 ":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
142 :co#80:dl=\033[M:do=\033[B:k0=\033[20~:k1=\033[1~:\
143 :k2=\033[2~:k3=\033[3~:k4=\033[4~:k5=\033[5~:k6=\033[6~:\
144 :k7=\033[17~:k8=\033[18~:k9=\033[19~:kd=\033[B:kh=\033[H:\
145 :kH=\033[Y:kI=\033[I:kl=\033[D:kN=\033[U:kP=\033[V:\
146 :kr=\033[C:ku=\033[A:li#24:md=\033[1m:me=\033[m:nd=\033[C:\
147 :se=\033[m:so=\033[7m:ti=\033[1;24r\033[24;1H:\
148 :ue=\033[m:up=\033[A:us=\033[4m:xn:",
162 ":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
163 :co#132:dl=\033[M:do=\033[B:k0=\033[20~:k1=\033[1~:\
164 :k2=\033[2~:k3=\033[3~:k4=\033[4~:k5=\033[5~:k6=\033[6~:\
165 :k7=\033[17~:k8=\033[18~:k9=\033[19~:kd=\033[B:kh=\033[H:\
166 :kH=\033[Y:kI=\033[I:kl=\033[D:kN=\033[U:kP=\033[V:\
167 :kr=\033[C:ku=\033[A:li#24:md=\033[1m:me=\033[m:nd=\033[C:\
168 :se=\033[m:so=\033[7m:ti=\033[1;24r\033[24;1H:\
169 :ue=\033[m:up=\033[A:us=\033[4m:xn:",
174 ":do=\n:le=\b:up=\033A:nd=\033C:cm=\033Y%+ %+ :ti=\033e\033v:\
175 :sr=\033I:cd=\033J:ce=\033K:cl=\033H\033J:co#80:li#24:\
176 :ku=\033A:kd=\033B:kr=\033C:kl=\033D:kb=\b:pt:am:xn:bs:",
183 ":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
184 :co#80:dl=\033[M:do=\033[B:k0=\033[20~:k1=\033[1~:\
185 :k2=\033[2~:k3=\033[3~:k4=\033[4~:k5=\033[5~:k6=\033[6~:\
186 :k7=\033[17~:k8=\033[18~:k9=\033[19~:kd=\033[B:kh=\033[H:\
187 :kH=\033[Y:kI=\033[I:kl=\033[D:kN=\033[U:kP=\033[V:\
188 :kr=\033[C:ku=\033[A:li#25:md=\033[1m:me=\033[m:nd=\033[C:\
189 :se=\033[m:so=\033[7m:ue=\033[m:up=\033[A:us=\033[4m:",
195 ":al=\033[L:am:bs:ce=\033[K:cl=\033[2J:cm=\033[%i%d;%dH:\
196 :co#80:dl=\033[M:do=\033[B:k0=\033[0x:k1=\033[1x:k2=\033[2x:\
197 :k3=\033[3x:k4=\033[4x:k5=\033[5x:k6=\033[6x:\
198 :k7=\033[7x:k8=\033[8x:k9=\033[9x:kd=\033[B:kh=\033[H:\
199 :kH=\033[24H:kI=\033[@:kl=\033[D:kN=\033[U:kP=\033[V:\
200 :kr=\033[C:ku=\033[A:li#24:md=\033[1m:me=\033[m:\
201 :nd=\033[C:se=\033[m:so=\033[7m:ue=\033[m:up=\033[A:\
203 #endif /* COHERENT */
208 ":al=\033L:am:bs:ce=\033K:cl=\033E:cm=\033Y%i%+ %+ :\
209 :co#80:dl=\033M:do=\033B:\
210 :k1=#;:k2=#<:k3=#=:k4=#>:k5=#?:k6=#@:k7=#A:k8=#B:k9=#C:k0=#D:\
211 :s1=#T:s2=#U:s3=#V:s4=#W:s5=#X:s6=#Y:s7=#Z:s8=#[:s9=#\\:s0=#]:\
212 :c1=#^:c2=#_:c3=#`:c4=#a:c5=#b:c6=#c:c7=#d:c8=#e:c9=#f:c0=#g:\
213 :a1=#h:a2=#i:a3=#j:a4=#k:a5=#l:a6=#m:a7=#n:a8=#o:a9=#p:a0=#q:\
214 kd=#P:kh=#G:kI=#R:kl=#K:kr=#M:ku=#H:li#25:nd=\033C:se=\033q:\
215 :so=\033p:te=:ti=\033e\033v:up=\033A:",
221 :hs:am:bs:co#80:li#24:cm=\033=%+ %+ :cl=\033*:cd=\033y:\
222 :ce=\033t:is=\033l\033\":\
223 :al=\033E:dl=\033R:im=:ei=:ic=\033Q:dc=\033W:\
224 :ho=\036:nd=\014:bt=\033I:pt:so=\033G4:se=\033G0:sg#1:us=\033G8:ue=\033G0:ug#1:\
225 :up=\013:do=\026:kb=\010:ku=\013:kd=\026:kl=\010:kr=\014:\
226 :kh=\036:ma=\026\012\014 :\
227 :k1=\001@\r:k2=\001A\r:k3=\001B\r:k4=\001C\r:k5=\001D\r:k6=\001E\r:k7=\001F\r:\
228 :k8=\001G\r:k9=\001H\r:k0=\001I\r:ko=ic,dc,al,dl,cl,ce,cd,bt:\
229 :ts=\033f:fs=\033g:ds=\033h:sr=\033j:", /* was :xn: for tvi925 alone*/
240 int tgetent(bp
, name
)
241 char *bp
; /* buffer for storing the entry -- ignored */
242 char *name
; /* name of the entry */
246 /* if TERMCAP is defined, and seems to match, then use it */
247 fields
= getenv("TERMCAP");
250 for (i
= 0; fields
[i
] && fields
[i
] != ':'; i
++)
252 if (!strncmp(fields
+ i
, name
, strlen(name
)))
259 /* locate the entry in termcap[] */
260 for (i
= 0; termcap
[i
] && strcmp(termcap
[i
], name
); i
++)
268 /* search forward for fields */
269 while (termcap
[i
][0] != ':')
278 static char *find(id
, vtype
)
279 char *id
; /* name of a value to locate */
280 int vtype
; /* '=' for strings, '#' for numbers, or 0 for bools */
284 /* search for a ':' followed by the two-letter id */
285 for (i
= 0; fields
[i
]; i
++)
288 && fields
[i
+ 1] == id
[0]
289 && fields
[i
+ 2] == id
[1])
291 /* if correct type, then return its value */
292 if (fields
[i
+ 3] == vtype
)
293 return &fields
[i
+ 4];
323 char *tgetstr(id
, bp
)
325 char **bp
; /* pointer to pointer to buffer - ignored */
329 /* find the string */
336 /* copy it into the buffer, and terminate it with NUL */
337 for (cpy
= *bp
; *id
!= ':'; )
339 if (id
[0] == '\\' && id
[1] == 'E')
340 *cpy
++ = '\033', id
+= 2;
346 /* update the bp pointer */
350 /* return a pointer to the copy of the string */
355 char *tgoto(cm
, destcol
, destrow
)
356 char *cm
; /* cursor movement string -- ignored */
357 int destcol
;/* destination column, 0 - 79 */
358 int destrow
;/* destination row, 0 - 24 */
364 sprintf(buf
, "\033Y%c%c", ' ' + destrow
, ' ' + destcol
);
366 sprintf(buf
, "\033[%d;%dH", destrow
+ 1, destcol
+ 1);
369 if (cm
[1] == 'Y' || cm
[1] == '=')
370 sprintf(buf
, "\033%c%c%c", cm
[1], ' ' + destrow
, ' ' + destcol
);
372 sprintf(buf
, "\033[%d;%dH", destrow
+ 1, destcol
+ 1);
378 void tputs(cp
, affcnt
, outfn
)
379 char *cp
; /* the string to output */
380 int affcnt
; /* number of affected lines -- ignored */
381 int (*outfn
)(); /* the output function */