xref: /freebsd/contrib/tcsh/ed.term.h (revision ce6a89e27cd190313be39bb479880aeda4778436)
1 /*
2  * ed.term.h: Local terminal header
3  */
4 /*-
5  * Copyright (c) 1980, 1991 The Regents of the University of California.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  */
32 #ifndef _h_ed_term
33 #define _h_ed_term
34 
35 #define TO_CONTROL(A)	((A) & 037)
36 
37 #if defined(TERMIO) || defined(POSIX)
38 /*
39  * Aix compatible names
40  */
41 # if defined(VWERSE) && !defined(VWERASE)
42 #  define VWERASE VWERSE
43 # endif /* VWERSE && !VWERASE */
44 
45 # if defined(VDISCRD) && !defined(VDISCARD)
46 #  define VDISCARD VDISCRD
47 # endif /* VDISCRD && !VDISCARD */
48 
49 # if defined(VFLUSHO) && !defined(VDISCARD)
50 #  define VDISCARD VFLUSHO
51 # endif  /* VFLUSHO && VDISCARD */
52 
53 # if defined(VSTRT) && !defined(VSTART)
54 #  define VSTART VSTRT
55 # endif /* VSTRT && ! VSTART */
56 
57 # if defined(VSTAT) && !defined(VSTATUS)
58 #  define VSTATUS VSTAT
59 # endif /* VSTAT && ! VSTATUS */
60 
61 # ifndef ONLRET
62 #  define ONLRET 0
63 # endif /* ONLRET */
64 
65 # ifndef TAB3
66 #  ifdef OXTABS
67 #   define TAB3 OXTABS
68 #  else
69 #   define TAB3 0
70 #  endif /* OXTABS */
71 # endif /* !TAB3 */
72 
73 # if defined(OXTABS) && !defined(XTABS)
74 #  define XTABS OXTABS
75 # endif /* OXTABS && !XTABS */
76 
77 # ifndef ONLCR
78 #  define ONLCR 0
79 # endif /* ONLCR */
80 
81 # ifndef IEXTEN
82 #  define IEXTEN 0
83 # endif /* IEXTEN */
84 
85 /*
86  * emx garbage
87  */
88 # ifndef IDEFAULT
89 #  define IDEFAULT 0
90 # endif /* IDEFAULT */
91 
92 # ifndef IDELETE
93 #  define IDELETE 0
94 # endif /* IDELETE */
95 
96 # ifndef ECHOCTL
97 #  define ECHOCTL 0
98 # endif /* ECHOCTL */
99 
100 # ifndef PARENB
101 #  define PARENB 0
102 # endif /* PARENB */
103 
104 # ifndef EXTPROC
105 #  define EXTPROC 0
106 # endif /* EXTPROC */
107 
108 # ifndef FLUSHO
109 #  define FLUSHO  0
110 # endif /* FLUSHO */
111 
112 
113 # if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
114 #  define _POSIX_VDISABLE VDISABLE
115 # endif /* VDISABLE && ! _POSIX_VDISABLE */
116 
117 /*
118  * Work around ISC's definition of IEXTEN which is
119  * XCASE!
120  */
121 # ifdef ISC
122 #  if defined(IEXTEN) && defined(XCASE)
123 #   if IEXTEN == XCASE
124 #    undef IEXTEN
125 #    define IEXTEN 0
126 #   endif /* IEXTEN == XCASE */
127 #  endif /* IEXTEN && XCASE */
128 #  if defined(IEXTEN) && !defined(XCASE)
129 #   define XCASE IEXTEN
130 #   undef IEXTEN
131 #   define IEXTEN 0
132 #  endif /* IEXTEN && !XCASE */
133 # endif /* ISC */
134 
135 /*
136  * Work around convex weirdness where turning off IEXTEN makes us
137  * lose all postprocessing!
138  */
139 #ifdef convex
140 # if defined(IEXTEN) && IEXTEN != 0
141 #  undef IEXTEN
142 #  define IEXTEN 0
143 # endif /* IEXTEN != 0 */
144 #endif /* convex */
145 
146 
147 # else /* SGTTY */
148 
149 # ifndef LPASS8
150 #  define LPASS8  0
151 # endif /* LPASS8 */
152 
153 #endif /* TERMIO || POSIX */
154 
155 #ifndef _POSIX_VDISABLE
156 # define _POSIX_VDISABLE ((unsigned char) -1)
157 #endif /* _POSIX_VDISABLE */
158 
159 
160 #if !defined(CREPRINT) && defined(CRPRNT)
161 # define CREPRINT CRPRNT
162 #endif /* !CREPRINT && CRPRNT */
163 #if !defined(CDISCARD) && defined(CFLUSH)
164 # define CDISCARD CFLUSH
165 #endif /* !CDISCARD && CFLUSH */
166 #if !defined(CDISCARD) && defined(CFLUSHO)
167 # define CDISCARD CFLUSHO
168 #endif /* !CDISCARD && CFLUSHO */
169 
170 /*
171  * IRIX4.0 control macro is broken!
172  * Ignore and undef all default tty chars defined and redefine only
173  * the ones that are different in the IRIX file.
174  */
175 #if __STDC__ && defined(IRIS4D)
176 # undef  CINTR
177 # define CINTR		0177	/* ^? */
178 # undef  CQUIT
179 # undef  CERASE
180 # define CERASE		TO_CONTROL('h')
181 # undef  CKILL
182 # undef  CEOF
183 # undef  CEOL
184 # undef  CEOL2
185 # undef  CSWTCH
186 # define CSWTCH		TO_CONTROL('z')
187 # undef  CDSWTCH
188 # undef  CERASE2
189 # undef  CSTART
190 # undef  CSTOP
191 # undef  CWERASE
192 # undef  CSUSP
193 # undef  CDSUSP
194 # undef  CREPRINT
195 # undef  CDISCARD
196 # undef  CLNEXT
197 # undef  CSTATUS
198 # undef  CPAGE
199 # undef  CPGOFF
200 # undef  CKILL2
201 # undef  CBRK
202 # undef  CMIN
203 # undef  CTIME
204 #endif /* __STDC__ && IRIS4D */
205 
206 
207 #ifndef CINTR
208 # define CINTR		TO_CONTROL('c')
209 #endif /* CINTR */
210 #ifndef CQUIT
211 # define CQUIT		034	/* ^\ */
212 #endif /* CQUIT */
213 #ifndef CERASE
214 # define CERASE		0177	/* ^? */
215 #endif /* CERASE */
216 #ifndef CKILL
217 # define CKILL		TO_CONTROL('u')
218 #endif /* CKILL */
219 #ifndef CEOF
220 # define CEOF		TO_CONTROL('d')
221 #endif /* CEOF */
222 #ifndef CEOL
223 # define CEOL		_POSIX_VDISABLE
224 #endif /* CEOL */
225 #ifndef CEOL2
226 # define CEOL2		_POSIX_VDISABLE
227 #endif /* CEOL2 */
228 #ifndef CSWTCH
229 # define CSWTCH		_POSIX_VDISABLE
230 #endif /* CSWTCH */
231 #ifndef CDSWTCH
232 # define CDSWTCH	_POSIX_VDISABLE
233 #endif /* CDSWTCH */
234 #ifndef CERASE2
235 # define CERASE2	_POSIX_VDISABLE
236 #endif /* CERASE2 */
237 #ifndef CSTART
238 # define CSTART		TO_CONTROL('q')
239 #endif /* CSTART */
240 #ifndef CSTOP
241 # define CSTOP		TO_CONTROL('s')
242 #endif /* CSTOP */
243 #ifndef CSUSP
244 # define CSUSP		TO_CONTROL('z')
245 #endif /* CSUSP */
246 #ifndef CDSUSP
247 # define CDSUSP		TO_CONTROL('y')
248 #endif /* CDSUSP */
249 
250 #ifdef hpux
251 
252 # ifndef CREPRINT
253 #  define CREPRINT	_POSIX_VDISABLE
254 # endif /* CREPRINT */
255 # ifndef CDISCARD
256 #  define CDISCARD	_POSIX_VDISABLE
257 # endif /* CDISCARD */
258 # ifndef CLNEXT
259 #  define CLNEXT	_POSIX_VDISABLE
260 # endif /* CLNEXT */
261 # ifndef CWERASE
262 #  define CWERASE	_POSIX_VDISABLE
263 # endif /* CWERASE */
264 
265 #else /* !hpux */
266 
267 # ifndef CREPRINT
268 #  define CREPRINT	TO_CONTROL('r')
269 # endif /* CREPRINT */
270 # ifndef CDISCARD
271 #  define CDISCARD	TO_CONTROL('o')
272 # endif /* CDISCARD */
273 # ifndef CLNEXT
274 #  define CLNEXT	TO_CONTROL('v')
275 # endif /* CLNEXT */
276 # ifndef CWERASE
277 #  define CWERASE	TO_CONTROL('w')
278 # endif /* CWERASE */
279 
280 #endif /* hpux */
281 
282 #ifndef CSTATUS
283 # define CSTATUS	TO_CONTROL('t')
284 #endif /* CSTATUS */
285 #ifndef CPAGE
286 # define CPAGE		' '
287 #endif /* CPAGE */
288 #ifndef CPGOFF
289 # define CPGOFF		TO_CONTROL('m')
290 #endif /* CPGOFF */
291 #ifndef CKILL2
292 # define CKILL2		_POSIX_VDISABLE
293 #endif /* CKILL2 */
294 #ifndef CBRK
295 # ifndef masscomp
296 #  define CBRK		0377
297 # else
298 #  define CBRK		'\0'
299 # endif /* masscomp */
300 #endif /* CBRK */
301 #ifndef CMIN
302 # if VMIN == VEOF
303 #  define CMIN		CEOF
304 # else
305 #  define CMIN		1
306 # endif
307 #endif /* CMIN */
308 #ifndef CTIME
309 # if VTIME == VEOL
310 #  define CTIME		CEOL
311 # else
312 #  define CTIME		0
313 # endif
314 #endif /* CTIME */
315 
316 /*
317  * Fix for sun inconsistency. On termio VSUSP and the rest of the
318  * ttychars > NCC are defined. So we undefine them.
319  */
320 #if defined(TERMIO) || defined(POSIX)
321 # if defined(POSIX) && defined(NCCS)
322 #  define NUMCC		NCCS
323 # else
324 #  ifdef NCC
325 #   define NUMCC	NCC
326 #  endif /* NCC */
327 # endif /* POSIX && NCCS */
328 # ifdef NUMCC
329 #  ifdef VINTR
330 #   if NUMCC <= VINTR
331 #    undef VINTR
332 #   endif /* NUMCC <= VINTR */
333 #  endif /* VINTR */
334 #  ifdef VQUIT
335 #   if NUMCC <= VQUIT
336 #    undef VQUIT
337 #   endif /* NUMCC <= VQUIT */
338 #  endif /* VQUIT */
339 #  ifdef VERASE
340 #   if NUMCC <= VERASE
341 #    undef VERASE
342 #   endif /* NUMCC <= VERASE */
343 #  endif /* VERASE */
344 #  ifdef VKILL
345 #   if NUMCC <= VKILL
346 #    undef VKILL
347 #   endif /* NUMCC <= VKILL */
348 #  endif /* VKILL */
349 #  ifdef VEOF
350 #   if NUMCC <= VEOF
351 #    undef VEOF
352 #   endif /* NUMCC <= VEOF */
353 #  endif /* VEOF */
354 #  ifdef VEOL
355 #   if NUMCC <= VEOL
356 #    undef VEOL
357 #   endif /* NUMCC <= VEOL */
358 #  endif /* VEOL */
359 #  ifdef VEOL2
360 #   if NUMCC <= VEOL2
361 #    undef VEOL2
362 #   endif /* NUMCC <= VEOL2 */
363 #  endif /* VEOL2 */
364 #  ifdef VSWTCH
365 #   if NUMCC <= VSWTCH
366 #    undef VSWTCH
367 #   endif /* NUMCC <= VSWTCH */
368 #  endif /* VSWTCH */
369 #  ifdef VDSWTCH
370 #   if NUMCC <= VDSWTCH
371 #    undef VDSWTCH
372 #   endif /* NUMCC <= VDSWTCH */
373 #  endif /* VDSWTCH */
374 #  ifdef VERASE2
375 #   if NUMCC <= VERASE2
376 #    undef VERASE2
377 #   endif /* NUMCC <= VERASE2 */
378 #  endif /* VERASE2 */
379 #  ifdef VSTART
380 #   if NUMCC <= VSTART
381 #    undef VSTART
382 #   endif /* NUMCC <= VSTART */
383 #  endif /* VSTART */
384 #  ifdef VSTOP
385 #   if NUMCC <= VSTOP
386 #    undef VSTOP
387 #   endif /* NUMCC <= VSTOP */
388 #  endif /* VSTOP */
389 #  ifdef VWERASE
390 #   if NUMCC <= VWERASE
391 #    undef VWERASE
392 #   endif /* NUMCC <= VWERASE */
393 #  endif /* VWERASE */
394 #  ifdef VSUSP
395 #   if NUMCC <= VSUSP
396 #    undef VSUSP
397 #   endif /* NUMCC <= VSUSP */
398 #  endif /* VSUSP */
399 #  ifdef VDSUSP
400 #   if NUMCC <= VDSUSP
401 #    undef VDSUSP
402 #   endif /* NUMCC <= VDSUSP */
403 #  endif /* VDSUSP */
404 #  ifdef VREPRINT
405 #   if NUMCC <= VREPRINT
406 #    undef VREPRINT
407 #   endif /* NUMCC <= VREPRINT */
408 #  endif /* VREPRINT */
409 #  ifdef VDISCARD
410 #   if NUMCC <= VDISCARD
411 #    undef VDISCARD
412 #   endif /* NUMCC <= VDISCARD */
413 #  endif /* VDISCARD */
414 #  ifdef VLNEXT
415 #   if NUMCC <= VLNEXT
416 #    undef VLNEXT
417 #   endif /* NUMCC <= VLNEXT */
418 #  endif /* VLNEXT */
419 #  ifdef VSTATUS
420 #   if NUMCC <= VSTATUS
421 #    undef VSTATUS
422 #   endif /* NUMCC <= VSTATUS */
423 #  endif /* VSTATUS */
424 #  ifdef VPAGE
425 #   if NUMCC <= VPAGE
426 #    undef VPAGE
427 #   endif /* NUMCC <= VPAGE */
428 #  endif /* VPAGE */
429 #  ifdef VPGOFF
430 #   if NUMCC <= VPGOFF
431 #    undef VPGOFF
432 #   endif /* NUMCC <= VPGOFF */
433 #  endif /* VPGOFF */
434 #  ifdef VKILL2
435 #   if NUMCC <= VKILL2
436 #    undef VKILL2
437 #   endif /* NUMCC <= VKILL2 */
438 #  endif /* VKILL2 */
439 #  ifdef VBRK
440 #   if NUMCC <= VBRK
441 #    undef VBRK
442 #   endif /* NUMCC <= VBRK */
443 #  endif /* VBRK */
444 #  ifdef VMIN
445 #   if NUMCC <= VMIN
446 #    undef VMIN
447 #   endif /* NUMCC <= VMIN */
448 #  endif /* VMIN */
449 #  ifdef VTIME
450 #   if NUMCC <= VTIME
451 #    undef VTIME
452 #   endif /* NUMCC <= VTIME */
453 #  endif /* VTIME */
454 # endif /* NUMCC */
455 #endif /* !POSIX */
456 
457 /*
458  * fix for hpux10 inconsistency: it has VWERASE, but TIOCSLTC returns
459  * EINVAL if one tries to change it
460  * Also for RH6.2 on the alpha, defined TIOCGLTC, but does not have
461  * struct ltchars
462  */
463 #if (defined(hpux) && defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT)) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__QNXNTO__)
464 # undef TIOCGLTC       /* not really needed */
465 # undef TIOCSLTC
466 #endif
467 
468 #define C_INTR		 0
469 #define C_QUIT		 1
470 #define C_ERASE		 2
471 #define C_KILL		 3
472 #define C_EOF		 4
473 #define C_EOL		 5
474 #define C_EOL2		 6
475 #define C_SWTCH		 7
476 #define C_DSWTCH	 8
477 #define C_ERASE2	 9
478 #define C_START		10
479 #define C_STOP		11
480 #define C_WERASE	12
481 #define C_SUSP		13
482 #define C_DSUSP		14
483 #define C_REPRINT	15
484 #define C_DISCARD	16
485 #define C_LNEXT		17
486 #define C_STATUS	18
487 #define C_PAGE		19
488 #define C_PGOFF		20
489 #define C_KILL2		21
490 #define C_BRK		22
491 #define C_MIN		23
492 #define C_TIME		24
493 #define C_NCC		25
494 #define C_SH(A)		(1 << (A))
495 
496 /*
497  * Terminal dependend data structures
498  */
499 typedef struct {
500 #ifdef WINNT_NATIVE
501     int dummy;
502 #else /* !WINNT_NATIVE */
503 # if defined(POSIX) || defined(TERMIO)
504 #  ifdef POSIX
505     struct termios d_t;
506 #  else
507     struct termio d_t;
508 #  endif /* POSIX */
509 # else /* SGTTY */
510 #  ifdef TIOCGETP
511     struct sgttyb d_t;
512 #  endif /* TIOCGETP */
513 #  ifdef TIOCGETC
514     struct tchars d_tc;
515 #  endif /* TIOCGETC */
516 #  ifdef TIOCGPAGE
517     struct ttypagestat d_pc;
518 #  endif /* TIOCGPAGE */
519 #  ifdef TIOCLGET
520     int d_lb;
521 #  endif /* TIOCLGET */
522 # endif /* POSIX || TERMIO */
523 # ifdef TIOCGLTC
524     struct ltchars d_ltc;
525 # endif /* TIOCGLTC */
526 #endif /* WINNT_NATIVE */
527 } ttydata_t;
528 
529 #endif /* _h_ed_term */
530