Merge branch 'vendor/TCSH'
[dragonfly.git] / contrib / tcsh-6 / ed.term.h
1 /* $Header: /p/tcsh/cvsroot/tcsh/ed.term.h,v 1.18 2007/07/05 14:13:06 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  CCHECKPT
200 # undef  CPAGE
201 # undef  CPGOFF
202 # undef  CKILL2
203 # undef  CBRK
204 # undef  CMIN
205 # undef  CTIME
206 #endif /* __STDC__ && IRIS4D */
207
208
209 #ifndef CINTR
210 # define CINTR          TO_CONTROL('c')
211 #endif /* CINTR */
212 #ifndef CQUIT
213 # define CQUIT          034     /* ^\ */
214 #endif /* CQUIT */
215 #ifndef CERASE
216 # define CERASE         0177    /* ^? */
217 #endif /* CERASE */
218 #ifndef CKILL
219 # define CKILL          TO_CONTROL('u')
220 #endif /* CKILL */
221 #ifndef CEOF
222 # define CEOF           TO_CONTROL('d')
223 #endif /* CEOF */
224 #ifndef CEOL
225 # define CEOL           _POSIX_VDISABLE
226 #endif /* CEOL */
227 #ifndef CEOL2
228 # define CEOL2          _POSIX_VDISABLE
229 #endif /* CEOL2 */
230 #ifndef CSWTCH
231 # define CSWTCH         _POSIX_VDISABLE
232 #endif /* CSWTCH */
233 #ifndef CDSWTCH
234 # define CDSWTCH        _POSIX_VDISABLE
235 #endif /* CDSWTCH */
236 #ifndef CERASE2
237 # define CERASE2        _POSIX_VDISABLE
238 #endif /* CERASE2 */
239 #ifndef CSTART
240 # define CSTART         TO_CONTROL('q')
241 #endif /* CSTART */
242 #ifndef CSTOP
243 # define CSTOP          TO_CONTROL('s')
244 #endif /* CSTOP */
245 #ifndef CSUSP
246 # define CSUSP          TO_CONTROL('z')
247 #endif /* CSUSP */
248 #ifndef CDSUSP
249 # define CDSUSP         TO_CONTROL('y')
250 #endif /* CDSUSP */
251
252 #ifdef hpux
253
254 # ifndef CREPRINT
255 #  define CREPRINT      _POSIX_VDISABLE
256 # endif /* CREPRINT */
257 # ifndef CDISCARD
258 #  define CDISCARD      _POSIX_VDISABLE
259 # endif /* CDISCARD */
260 # ifndef CLNEXT
261 #  define CLNEXT        _POSIX_VDISABLE
262 # endif /* CLNEXT */
263 # ifndef CWERASE
264 #  define CWERASE       _POSIX_VDISABLE
265 # endif /* CWERASE */
266
267 #else /* !hpux */
268
269 # ifndef CREPRINT
270 #  define CREPRINT      TO_CONTROL('r')
271 # endif /* CREPRINT */
272 # ifndef CDISCARD
273 #  define CDISCARD      TO_CONTROL('o')
274 # endif /* CDISCARD */
275 # ifndef CLNEXT
276 #  define CLNEXT        TO_CONTROL('v')
277 # endif /* CLNEXT */
278 # ifndef CWERASE
279 #  define CWERASE       TO_CONTROL('w')
280 # endif /* CWERASE */
281
282 #endif /* hpux */
283
284 #ifndef CSTATUS
285 # define CSTATUS        TO_CONTROL('t')
286 #endif /* CSTATUS */
287 #ifndef CCHECKPT
288 # define CCHECKPT       TO_CONTROL('e')
289 #endif /* CCHECKPT */
290 #ifndef CPAGE
291 # define CPAGE          ' '
292 #endif /* CPAGE */
293 #ifndef CPGOFF
294 # define CPGOFF         TO_CONTROL('m')
295 #endif /* CPGOFF */
296 #ifndef CKILL2
297 # define CKILL2         _POSIX_VDISABLE
298 #endif /* CKILL2 */
299 #ifndef CBRK
300 # ifndef masscomp
301 #  define CBRK          0377
302 # else
303 #  define CBRK          '\0'
304 # endif /* masscomp */
305 #endif /* CBRK */
306 #ifndef CMIN
307 # define CMIN           CEOF
308 #endif /* CMIN */
309 #ifndef CTIME
310 # define CTIME          CEOL
311 #endif /* CTIME */
312
313 /*
314  * Fix for sun inconsistency. On termio VSUSP and the rest of the
315  * ttychars > NCC are defined. So we undefine them.
316  */
317 #if defined(TERMIO) || defined(POSIX)
318 # if defined(POSIX) && defined(NCCS)
319 #  define NUMCC         NCCS
320 # else
321 #  ifdef NCC
322 #   define NUMCC        NCC
323 #  endif /* NCC */
324 # endif /* POSIX && NCCS */
325 # ifdef NUMCC
326 #  ifdef VINTR
327 #   if NUMCC <= VINTR
328 #    undef VINTR
329 #   endif /* NUMCC <= VINTR */
330 #  endif /* VINTR */
331 #  ifdef VQUIT
332 #   if NUMCC <= VQUIT
333 #    undef VQUIT
334 #   endif /* NUMCC <= VQUIT */
335 #  endif /* VQUIT */
336 #  ifdef VERASE
337 #   if NUMCC <= VERASE
338 #    undef VERASE
339 #   endif /* NUMCC <= VERASE */
340 #  endif /* VERASE */
341 #  ifdef VKILL
342 #   if NUMCC <= VKILL
343 #    undef VKILL
344 #   endif /* NUMCC <= VKILL */
345 #  endif /* VKILL */
346 #  ifdef VEOF
347 #   if NUMCC <= VEOF
348 #    undef VEOF
349 #   endif /* NUMCC <= VEOF */
350 #  endif /* VEOF */
351 #  ifdef VEOL
352 #   if NUMCC <= VEOL
353 #    undef VEOL
354 #   endif /* NUMCC <= VEOL */
355 #  endif /* VEOL */
356 #  ifdef VEOL2
357 #   if NUMCC <= VEOL2
358 #    undef VEOL2
359 #   endif /* NUMCC <= VEOL2 */
360 #  endif /* VEOL2 */
361 #  ifdef VSWTCH
362 #   if NUMCC <= VSWTCH
363 #    undef VSWTCH
364 #   endif /* NUMCC <= VSWTCH */
365 #  endif /* VSWTCH */
366 #  ifdef VDSWTCH
367 #   if NUMCC <= VDSWTCH
368 #    undef VDSWTCH
369 #   endif /* NUMCC <= VDSWTCH */
370 #  endif /* VDSWTCH */
371 #  ifdef VERASE2
372 #   if NUMCC <= VERASE2
373 #    undef VERASE2
374 #   endif /* NUMCC <= VERASE2 */
375 #  endif /* VERASE2 */
376 #  ifdef VSTART
377 #   if NUMCC <= VSTART
378 #    undef VSTART
379 #   endif /* NUMCC <= VSTART */
380 #  endif /* VSTART */
381 #  ifdef VSTOP
382 #   if NUMCC <= VSTOP
383 #    undef VSTOP
384 #   endif /* NUMCC <= VSTOP */
385 #  endif /* VSTOP */
386 #  ifdef VWERASE
387 #   if NUMCC <= VWERASE
388 #    undef VWERASE
389 #   endif /* NUMCC <= VWERASE */
390 #  endif /* VWERASE */
391 #  ifdef VSUSP
392 #   if NUMCC <= VSUSP
393 #    undef VSUSP
394 #   endif /* NUMCC <= VSUSP */
395 #  endif /* VSUSP */
396 #  ifdef VDSUSP
397 #   if NUMCC <= VDSUSP
398 #    undef VDSUSP
399 #   endif /* NUMCC <= VDSUSP */
400 #  endif /* VDSUSP */
401 #  ifdef VREPRINT
402 #   if NUMCC <= VREPRINT
403 #    undef VREPRINT
404 #   endif /* NUMCC <= VREPRINT */
405 #  endif /* VREPRINT */
406 #  ifdef VDISCARD
407 #   if NUMCC <= VDISCARD
408 #    undef VDISCARD
409 #   endif /* NUMCC <= VDISCARD */
410 #  endif /* VDISCARD */
411 #  ifdef VLNEXT
412 #   if NUMCC <= VLNEXT
413 #    undef VLNEXT
414 #   endif /* NUMCC <= VLNEXT */
415 #  endif /* VLNEXT */
416 #  ifdef VSTATUS
417 #   if NUMCC <= VSTATUS
418 #    undef VSTATUS
419 #   endif /* NUMCC <= VSTATUS */
420 #  endif /* VSTATUS */
421 #  ifdef VCHECKPT
422 #   if NUMCC <= VCHECKPT
423 #    undef VCHECKPT
424 #   endif /* NUMCC <= VCHECKPT */
425 #  endif /* VCHECKPT */
426 #  ifdef VPAGE
427 #   if NUMCC <= VPAGE
428 #    undef VPAGE
429 #   endif /* NUMCC <= VPAGE */
430 #  endif /* VPAGE */
431 #  ifdef VPGOFF
432 #   if NUMCC <= VPGOFF
433 #    undef VPGOFF
434 #   endif /* NUMCC <= VPGOFF */
435 #  endif /* VPGOFF */
436 #  ifdef VKILL2
437 #   if NUMCC <= VKILL2
438 #    undef VKILL2
439 #   endif /* NUMCC <= VKILL2 */
440 #  endif /* VKILL2 */
441 #  ifdef VBRK
442 #   if NUMCC <= VBRK
443 #    undef VBRK
444 #   endif /* NUMCC <= VBRK */
445 #  endif /* VBRK */
446 #  ifdef VMIN
447 #   if NUMCC <= VMIN
448 #    undef VMIN
449 #   endif /* NUMCC <= VMIN */
450 #  endif /* VMIN */
451 #  ifdef VTIME
452 #   if NUMCC <= VTIME
453 #    undef VTIME
454 #   endif /* NUMCC <= VTIME */
455 #  endif /* VTIME */
456 # endif /* NUMCC */
457 #endif /* !POSIX */
458
459 /*
460  * fix for hpux10 inconsistency: it has VWERASE, but TIOCSLTC returns
461  * EINVAL if one tries to change it
462  * Also for RH6.2 on the alpha, defined TIOCGLTC, but does not have
463  * struct ltchars
464  */
465 #if (defined(hpux) && defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT)) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__QNXNTO__)
466 # undef TIOCGLTC       /* not really needed */
467 # undef TIOCSLTC
468 #endif
469
470 #define C_INTR           0
471 #define C_QUIT           1
472 #define C_ERASE          2
473 #define C_KILL           3
474 #define C_EOF            4
475 #define C_EOL            5
476 #define C_EOL2           6
477 #define C_SWTCH          7
478 #define C_DSWTCH         8
479 #define C_ERASE2         9
480 #define C_START         10
481 #define C_STOP          11
482 #define C_WERASE        12
483 #define C_SUSP          13
484 #define C_DSUSP         14
485 #define C_REPRINT       15
486 #define C_DISCARD       16
487 #define C_LNEXT         17
488 #define C_STATUS        18
489 #define C_PAGE          19
490 #define C_PGOFF         20
491 #define C_KILL2         21
492 #define C_BRK           22
493 #define C_MIN           23
494 #define C_TIME          24
495 #define C_CHECKPT       25
496 #define C_NCC           26
497 #define C_SH(A)         (1 << (A))
498
499 /*
500  * Terminal dependend data structures
501  */
502 typedef struct {
503 #ifdef WINNT_NATIVE
504     int dummy;
505 #else /* !WINNT_NATIVE */
506 # if defined(POSIX) || defined(TERMIO)
507 #  ifdef POSIX
508     struct termios d_t;
509 #  else
510     struct termio d_t;
511 #  endif /* POSIX */
512 # else /* SGTTY */
513 #  ifdef TIOCGETP
514     struct sgttyb d_t;
515 #  endif /* TIOCGETP */
516 #  ifdef TIOCGETC
517     struct tchars d_tc;
518 #  endif /* TIOCGETC */
519 #  ifdef TIOCGPAGE
520     struct ttypagestat d_pc;
521 #  endif /* TIOCGPAGE */
522 #  ifdef TIOCLGET
523     int d_lb;
524 #  endif /* TIOCLGET */
525 # endif /* POSIX || TERMIO */
526 # ifdef TIOCGLTC
527     struct ltchars d_ltc;
528 # endif /* TIOCGLTC */
529 #endif /* WINNT_NATIVE */
530 } ttydata_t;
531
532 #endif /* _h_ed_term */