ed.term.h revision 225736
122347Spst/* $Header: /p/tcsh/cvsroot/tcsh/ed.term.h,v 1.18 2007/07/05 14:13:06 christos Exp $ */
222347Spst/*
322347Spst * ed.term.h: Local terminal header
422347Spst */
522347Spst/*-
622347Spst * Copyright (c) 1980, 1991 The Regents of the University of California.
722347Spst * All rights reserved.
822347Spst *
922347Spst * Redistribution and use in source and binary forms, with or without
1022347Spst * modification, are permitted provided that the following conditions
1129964Sache * are met:
1229964Sache * 1. Redistributions of source code must retain the above copyright
1322347Spst *    notice, this list of conditions and the following disclaimer.
1422347Spst * 2. Redistributions in binary form must reproduce the above copyright
1522347Spst *    notice, this list of conditions and the following disclaimer in the
1622347Spst *    documentation and/or other materials provided with the distribution.
1722347Spst * 3. Neither the name of the University nor the names of its contributors
1822347Spst *    may be used to endorse or promote products derived from this software
1929964Sache *    without specific prior written permission.
2029964Sache *
2129964Sache * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
2222347Spst * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
2322347Spst * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
2422347Spst * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
2522347Spst * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2622347Spst * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2722347Spst * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2822347Spst * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
2922347Spst * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
3022347Spst * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
3122347Spst * SUCH DAMAGE.
3222347Spst */
3322347Spst#ifndef _h_ed_term
3422347Spst#define _h_ed_term
3522347Spst
3622347Spst#define TO_CONTROL(A)	((A) & 037)
3722347Spst
3822347Spst#if defined(TERMIO) || defined(POSIX)
3922347Spst/*
4022347Spst * Aix compatible names
4122347Spst */
4222347Spst# if defined(VWERSE) && !defined(VWERASE)
4322347Spst#  define VWERASE VWERSE
4422347Spst# endif /* VWERSE && !VWERASE */
4522347Spst
4622347Spst# if defined(VDISCRD) && !defined(VDISCARD)
4722347Spst#  define VDISCARD VDISCRD
4822347Spst# endif /* VDISCRD && !VDISCARD */
4922347Spst
5022347Spst# if defined(VFLUSHO) && !defined(VDISCARD)
5122347Spst#  define VDISCARD VFLUSHO
5222347Spst# endif  /* VFLUSHO && VDISCARD */
5322347Spst
5422347Spst# if defined(VSTRT) && !defined(VSTART)
5522347Spst#  define VSTART VSTRT
5622347Spst# endif /* VSTRT && ! VSTART */
5722347Spst
5822347Spst# if defined(VSTAT) && !defined(VSTATUS)
5922347Spst#  define VSTATUS VSTAT
6022347Spst# endif /* VSTAT && ! VSTATUS */
6122347Spst
6222347Spst# ifndef ONLRET
6322347Spst#  define ONLRET 0
6422347Spst# endif /* ONLRET */
6522347Spst
6622347Spst# ifndef TAB3
6722347Spst#  ifdef OXTABS
6822347Spst#   define TAB3 OXTABS
6922347Spst#  else
7022347Spst#   define TAB3 0
7122347Spst#  endif /* OXTABS */
7222347Spst# endif /* !TAB3 */
7322347Spst
7422347Spst# if defined(OXTABS) && !defined(XTABS)
7522347Spst#  define XTABS OXTABS
7622347Spst# endif /* OXTABS && !XTABS */
7722347Spst
7822347Spst# ifndef ONLCR
7922347Spst#  define ONLCR 0
8022347Spst# endif /* ONLCR */
8122347Spst
8222347Spst# ifndef IEXTEN
8322347Spst#  define IEXTEN 0
8422347Spst# endif /* IEXTEN */
8522347Spst
8622347Spst/*
8722347Spst * emx garbage
8822347Spst */
8922347Spst# ifndef IDEFAULT
9022347Spst#  define IDEFAULT 0
9122347Spst# endif /* IDEFAULT */
9222347Spst
9322347Spst# ifndef IDELETE
9422347Spst#  define IDELETE 0
9522347Spst# endif /* IDELETE */
9622347Spst
9722347Spst# ifndef ECHOCTL
9822347Spst#  define ECHOCTL 0
9922347Spst# endif /* ECHOCTL */
10022347Spst
10122347Spst# ifndef PARENB
10222347Spst#  define PARENB 0
10322347Spst# endif /* PARENB */
10422347Spst
10522347Spst# ifndef EXTPROC
10622347Spst#  define EXTPROC 0
10722347Spst# endif /* EXTPROC */
10822347Spst
10922347Spst# ifndef FLUSHO
11022347Spst#  define FLUSHO  0
11122347Spst# endif /* FLUSHO */
11222347Spst
11322347Spst
11422347Spst# if defined(VDISABLE) && !defined(_POSIX_VDISABLE)
11522347Spst#  define _POSIX_VDISABLE VDISABLE
11622347Spst# endif /* VDISABLE && ! _POSIX_VDISABLE */
11722347Spst
11822347Spst/*
11922347Spst * Work around ISC's definition of IEXTEN which is
12022347Spst * XCASE!
12122347Spst */
12222347Spst# ifdef ISC
12322347Spst#  if defined(IEXTEN) && defined(XCASE)
12422347Spst#   if IEXTEN == XCASE
12522347Spst#    undef IEXTEN
12622347Spst#    define IEXTEN 0
12722347Spst#   endif /* IEXTEN == XCASE */
12822347Spst#  endif /* IEXTEN && XCASE */
12922347Spst#  if defined(IEXTEN) && !defined(XCASE)
13022347Spst#   define XCASE IEXTEN
13122347Spst#   undef IEXTEN
13222347Spst#   define IEXTEN 0
13322347Spst#  endif /* IEXTEN && !XCASE */
13422347Spst# endif /* ISC */
13522347Spst
13622347Spst/*
13722347Spst * Work around convex weirdness where turning off IEXTEN makes us
13822347Spst * lose all postprocessing!
13922347Spst */
14022347Spst#ifdef convex
14122347Spst# if defined(IEXTEN) && IEXTEN != 0
14222347Spst#  undef IEXTEN
14329964Sache#  define IEXTEN 0
14429964Sache# endif /* IEXTEN != 0 */
14529964Sache#endif /* convex */
14629964Sache
14729964Sache
14829964Sache# else /* SGTTY */
14929964Sache
15022347Spst# ifndef LPASS8
15122347Spst#  define LPASS8  0
15222347Spst# endif /* LPASS8 */
15322347Spst
15422347Spst#endif /* TERMIO || POSIX */
15522347Spst
15622347Spst#ifndef _POSIX_VDISABLE
15722347Spst# define _POSIX_VDISABLE ((unsigned char) -1)
15822347Spst#endif /* _POSIX_VDISABLE */
15922347Spst
16022347Spst
16122347Spst#if !defined(CREPRINT) && defined(CRPRNT)
16222347Spst# define CREPRINT CRPRNT
16322347Spst#endif /* !CREPRINT && CRPRNT */
16422347Spst#if !defined(CDISCARD) && defined(CFLUSH)
16522347Spst# define CDISCARD CFLUSH
16622347Spst#endif /* !CDISCARD && CFLUSH */
16722347Spst#if !defined(CDISCARD) && defined(CFLUSHO)
16822347Spst# define CDISCARD CFLUSHO
16929964Sache#endif /* !CDISCARD && CFLUSHO */
17029964Sache
17129964Sache/*
17222347Spst * IRIX4.0 control macro is broken!
17322347Spst * Ignore and undef all default tty chars defined and redefine only
17422347Spst * the ones that are different in the IRIX file.
17522347Spst */
17622347Spst#if __STDC__ && defined(IRIS4D)
17722347Spst# undef  CINTR
17822347Spst# define CINTR		0177	/* ^? */
17922347Spst# undef  CQUIT
18022347Spst# undef  CERASE
18122347Spst# define CERASE		TO_CONTROL('h')
18222347Spst# undef  CKILL
18322347Spst# undef  CEOF
18422347Spst# undef  CEOL
18522347Spst# undef  CEOL2
18622347Spst# undef  CSWTCH
18722347Spst# define CSWTCH		TO_CONTROL('z')
18822347Spst# undef  CDSWTCH
18922347Spst# undef  CERASE2
19022347Spst# undef  CSTART
19122347Spst# undef  CSTOP
19222347Spst# undef  CWERASE
19329964Sache# undef  CSUSP
19429964Sache# undef  CDSUSP
19529964Sache# undef  CREPRINT
19629964Sache# undef  CDISCARD
19729964Sache# undef  CLNEXT
19829964Sache# undef  CSTATUS
19929964Sache# undef  CPAGE
20029964Sache# undef  CPGOFF
20129964Sache# undef  CKILL2
20229964Sache# undef  CBRK
20329964Sache# undef  CMIN
20429964Sache# undef  CTIME
20522347Spst#endif /* __STDC__ && IRIS4D */
20622347Spst
20722347Spst
20822347Spst#ifndef CINTR
20929964Sache# define CINTR		TO_CONTROL('c')
21029964Sache#endif /* CINTR */
21129964Sache#ifndef CQUIT
21222347Spst# define CQUIT		034	/* ^\ */
21322347Spst#endif /* CQUIT */
21422347Spst#ifndef CERASE
21522347Spst# define CERASE		0177	/* ^? */
21622347Spst#endif /* CERASE */
21722347Spst#ifndef CKILL
21822347Spst# define CKILL		TO_CONTROL('u')
21922347Spst#endif /* CKILL */
22022347Spst#ifndef CEOF
22122347Spst# define CEOF		TO_CONTROL('d')
22222347Spst#endif /* CEOF */
22322347Spst#ifndef CEOL
22422347Spst# define CEOL		_POSIX_VDISABLE
22522347Spst#endif /* CEOL */
22622347Spst#ifndef CEOL2
22722347Spst# define CEOL2		_POSIX_VDISABLE
22822347Spst#endif /* CEOL2 */
22922347Spst#ifndef CSWTCH
23022347Spst# define CSWTCH		_POSIX_VDISABLE
23122347Spst#endif /* CSWTCH */
23229964Sache#ifndef CDSWTCH
23322347Spst# define CDSWTCH	_POSIX_VDISABLE
23422347Spst#endif /* CDSWTCH */
23522347Spst#ifndef CERASE2
23622347Spst# define CERASE2	_POSIX_VDISABLE
23729964Sache#endif /* CERASE2 */
23822347Spst#ifndef CSTART
23922347Spst# define CSTART		TO_CONTROL('q')
24029964Sache#endif /* CSTART */
24122347Spst#ifndef CSTOP
24222347Spst# define CSTOP		TO_CONTROL('s')
24329964Sache#endif /* CSTOP */
24422347Spst#ifndef CSUSP
24522347Spst# define CSUSP		TO_CONTROL('z')
24622347Spst#endif /* CSUSP */
24722347Spst#ifndef CDSUSP
24822347Spst# define CDSUSP		TO_CONTROL('y')
24922347Spst#endif /* CDSUSP */
25029964Sache
25129964Sache#ifdef hpux
25229964Sache
25329964Sache# ifndef CREPRINT
25422347Spst#  define CREPRINT	_POSIX_VDISABLE
25529964Sache# endif /* CREPRINT */
25629964Sache# ifndef CDISCARD
25729964Sache#  define CDISCARD	_POSIX_VDISABLE
25829964Sache# endif /* CDISCARD */
25929964Sache# ifndef CLNEXT
26022347Spst#  define CLNEXT	_POSIX_VDISABLE
26122347Spst# endif /* CLNEXT */
26222347Spst# ifndef CWERASE
26322347Spst#  define CWERASE	_POSIX_VDISABLE
26422347Spst# endif /* CWERASE */
26522347Spst
26622347Spst#else /* !hpux */
26729964Sache
26829964Sache# ifndef CREPRINT
26929964Sache#  define CREPRINT	TO_CONTROL('r')
27029964Sache# endif /* CREPRINT */
27129964Sache# ifndef CDISCARD
27229964Sache#  define CDISCARD	TO_CONTROL('o')
27329964Sache# endif /* CDISCARD */
27429964Sache# ifndef CLNEXT
27529964Sache#  define CLNEXT	TO_CONTROL('v')
27629964Sache# endif /* CLNEXT */
27729964Sache# ifndef CWERASE
27829964Sache#  define CWERASE	TO_CONTROL('w')
27929964Sache# endif /* CWERASE */
28029964Sache
28129964Sache#endif /* hpux */
28222347Spst
28322347Spst#ifndef CSTATUS
28422347Spst# define CSTATUS	TO_CONTROL('t')
28529964Sache#endif /* CSTATUS */
28622347Spst#ifndef CPAGE
28722347Spst# define CPAGE		' '
28822347Spst#endif /* CPAGE */
28922347Spst#ifndef CPGOFF
29022347Spst# define CPGOFF		TO_CONTROL('m')
29122347Spst#endif /* CPGOFF */
29222347Spst#ifndef CKILL2
29322347Spst# define CKILL2		_POSIX_VDISABLE
29422347Spst#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# define CMIN		CEOF
304#endif /* CMIN */
305#ifndef CTIME
306# define CTIME		CEOL
307#endif /* CTIME */
308
309/*
310 * Fix for sun inconsistency. On termio VSUSP and the rest of the
311 * ttychars > NCC are defined. So we undefine them.
312 */
313#if defined(TERMIO) || defined(POSIX)
314# if defined(POSIX) && defined(NCCS)
315#  define NUMCC		NCCS
316# else
317#  ifdef NCC
318#   define NUMCC	NCC
319#  endif /* NCC */
320# endif /* POSIX && NCCS */
321# ifdef NUMCC
322#  ifdef VINTR
323#   if NUMCC <= VINTR
324#    undef VINTR
325#   endif /* NUMCC <= VINTR */
326#  endif /* VINTR */
327#  ifdef VQUIT
328#   if NUMCC <= VQUIT
329#    undef VQUIT
330#   endif /* NUMCC <= VQUIT */
331#  endif /* VQUIT */
332#  ifdef VERASE
333#   if NUMCC <= VERASE
334#    undef VERASE
335#   endif /* NUMCC <= VERASE */
336#  endif /* VERASE */
337#  ifdef VKILL
338#   if NUMCC <= VKILL
339#    undef VKILL
340#   endif /* NUMCC <= VKILL */
341#  endif /* VKILL */
342#  ifdef VEOF
343#   if NUMCC <= VEOF
344#    undef VEOF
345#   endif /* NUMCC <= VEOF */
346#  endif /* VEOF */
347#  ifdef VEOL
348#   if NUMCC <= VEOL
349#    undef VEOL
350#   endif /* NUMCC <= VEOL */
351#  endif /* VEOL */
352#  ifdef VEOL2
353#   if NUMCC <= VEOL2
354#    undef VEOL2
355#   endif /* NUMCC <= VEOL2 */
356#  endif /* VEOL2 */
357#  ifdef VSWTCH
358#   if NUMCC <= VSWTCH
359#    undef VSWTCH
360#   endif /* NUMCC <= VSWTCH */
361#  endif /* VSWTCH */
362#  ifdef VDSWTCH
363#   if NUMCC <= VDSWTCH
364#    undef VDSWTCH
365#   endif /* NUMCC <= VDSWTCH */
366#  endif /* VDSWTCH */
367#  ifdef VERASE2
368#   if NUMCC <= VERASE2
369#    undef VERASE2
370#   endif /* NUMCC <= VERASE2 */
371#  endif /* VERASE2 */
372#  ifdef VSTART
373#   if NUMCC <= VSTART
374#    undef VSTART
375#   endif /* NUMCC <= VSTART */
376#  endif /* VSTART */
377#  ifdef VSTOP
378#   if NUMCC <= VSTOP
379#    undef VSTOP
380#   endif /* NUMCC <= VSTOP */
381#  endif /* VSTOP */
382#  ifdef VWERASE
383#   if NUMCC <= VWERASE
384#    undef VWERASE
385#   endif /* NUMCC <= VWERASE */
386#  endif /* VWERASE */
387#  ifdef VSUSP
388#   if NUMCC <= VSUSP
389#    undef VSUSP
390#   endif /* NUMCC <= VSUSP */
391#  endif /* VSUSP */
392#  ifdef VDSUSP
393#   if NUMCC <= VDSUSP
394#    undef VDSUSP
395#   endif /* NUMCC <= VDSUSP */
396#  endif /* VDSUSP */
397#  ifdef VREPRINT
398#   if NUMCC <= VREPRINT
399#    undef VREPRINT
400#   endif /* NUMCC <= VREPRINT */
401#  endif /* VREPRINT */
402#  ifdef VDISCARD
403#   if NUMCC <= VDISCARD
404#    undef VDISCARD
405#   endif /* NUMCC <= VDISCARD */
406#  endif /* VDISCARD */
407#  ifdef VLNEXT
408#   if NUMCC <= VLNEXT
409#    undef VLNEXT
410#   endif /* NUMCC <= VLNEXT */
411#  endif /* VLNEXT */
412#  ifdef VSTATUS
413#   if NUMCC <= VSTATUS
414#    undef VSTATUS
415#   endif /* NUMCC <= VSTATUS */
416#  endif /* VSTATUS */
417#  ifdef VPAGE
418#   if NUMCC <= VPAGE
419#    undef VPAGE
420#   endif /* NUMCC <= VPAGE */
421#  endif /* VPAGE */
422#  ifdef VPGOFF
423#   if NUMCC <= VPGOFF
424#    undef VPGOFF
425#   endif /* NUMCC <= VPGOFF */
426#  endif /* VPGOFF */
427#  ifdef VKILL2
428#   if NUMCC <= VKILL2
429#    undef VKILL2
430#   endif /* NUMCC <= VKILL2 */
431#  endif /* VKILL2 */
432#  ifdef VBRK
433#   if NUMCC <= VBRK
434#    undef VBRK
435#   endif /* NUMCC <= VBRK */
436#  endif /* VBRK */
437#  ifdef VMIN
438#   if NUMCC <= VMIN
439#    undef VMIN
440#   endif /* NUMCC <= VMIN */
441#  endif /* VMIN */
442#  ifdef VTIME
443#   if NUMCC <= VTIME
444#    undef VTIME
445#   endif /* NUMCC <= VTIME */
446#  endif /* VTIME */
447# endif /* NUMCC */
448#endif /* !POSIX */
449
450/*
451 * fix for hpux10 inconsistency: it has VWERASE, but TIOCSLTC returns
452 * EINVAL if one tries to change it
453 * Also for RH6.2 on the alpha, defined TIOCGLTC, but does not have
454 * struct ltchars
455 */
456#if (defined(hpux) && defined(VSUSP) && defined(VDSUSP) && defined(VWERASE) && defined(VLNEXT)) || defined(__linux__) || defined(__GNU__) || defined(__GLIBC__) || defined(__QNXNTO__)
457# undef TIOCGLTC       /* not really needed */
458# undef TIOCSLTC
459#endif
460
461#define C_INTR		 0
462#define C_QUIT		 1
463#define C_ERASE		 2
464#define C_KILL		 3
465#define C_EOF		 4
466#define C_EOL		 5
467#define C_EOL2		 6
468#define C_SWTCH		 7
469#define C_DSWTCH	 8
470#define C_ERASE2	 9
471#define C_START		10
472#define C_STOP		11
473#define C_WERASE	12
474#define C_SUSP		13
475#define C_DSUSP		14
476#define C_REPRINT	15
477#define C_DISCARD	16
478#define C_LNEXT		17
479#define C_STATUS	18
480#define C_PAGE		19
481#define C_PGOFF		20
482#define C_KILL2		21
483#define C_BRK		22
484#define C_MIN		23
485#define C_TIME		24
486#define C_NCC		25
487#define C_SH(A)		(1 << (A))
488
489/*
490 * Terminal dependend data structures
491 */
492typedef struct {
493#ifdef WINNT_NATIVE
494    int dummy;
495#else /* !WINNT_NATIVE */
496# if defined(POSIX) || defined(TERMIO)
497#  ifdef POSIX
498    struct termios d_t;
499#  else
500    struct termio d_t;
501#  endif /* POSIX */
502# else /* SGTTY */
503#  ifdef TIOCGETP
504    struct sgttyb d_t;
505#  endif /* TIOCGETP */
506#  ifdef TIOCGETC
507    struct tchars d_tc;
508#  endif /* TIOCGETC */
509#  ifdef TIOCGPAGE
510    struct ttypagestat d_pc;
511#  endif /* TIOCGPAGE */
512#  ifdef TIOCLGET
513    int d_lb;
514#  endif /* TIOCLGET */
515# endif /* POSIX || TERMIO */
516# ifdef TIOCGLTC
517    struct ltchars d_ltc;
518# endif /* TIOCGLTC */
519#endif /* WINNT_NATIVE */
520} ttydata_t;
521
522#endif /* _h_ed_term */
523