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