xref: /titanic_51/usr/src/cmd/vi/port/ex_tty.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1995 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
28 /*	  All Rights Reserved  	*/
29 
30 
31 /* Copyright (c) 1981 Regents of the University of California */
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 /*
36  * Capabilities from termcap
37  *
38  * The description of terminals is a difficult business, and we only
39  * attempt to summarize the capabilities here;  for a full description
40  * see the paper describing termcap.
41  *
42  * Capabilities from termcap are of three kinds - string valued options,
43  * numeric valued options, and boolean options.  The string valued options
44  * are the most complicated, since they may include padding information,
45  * which we describe now.
46  *
47  * Intelligent terminals often require padding on intelligent operations
48  * at high (and sometimes even low) speed.  This is specified by
49  * a number before the string in the capability, and has meaning for the
50  * capabilities which have a P at the front of their comment.
51  * This normally is a number of milliseconds to pad the operation.
52  * In the current system which has no true programmable delays, we
53  * do this by sending a sequence of pad characters (normally nulls, but
54  * specifiable as "pc").  In some cases, the pad is better computed
55  * as some number of milliseconds times the number of affected lines
56  * (to bottom of screen usually, except when terminals have insert modes
57  * which will shift several lines.)  This is specified as '12*' e.g.
58  * before the capability to say 12 milliseconds per affected whatever
59  * (currently always line).  Capabilities where this makes sense say P*.
60  */
61 
62 /*
63  * From the tty modes...
64  */
65 var	bool	NONL;		/* Terminal can't hack linefeeds doing a CR */
66 var	bool	UPPERCASE;
67 var	short	OCOLUMNS;	/* Save columns for a hack in open mode */
68 
69 var	short	outcol;		/* Where the cursor is */
70 var	short	outline;
71 
72 var	short	destcol;	/* Where the cursor should be */
73 var	short	destline;
74 
75 /*
76  * There are several kinds of tty drivers to contend with.  These include:
77  * (1)	V6:		no CBREAK, no ioctl.  (Include PWB V1 here).
78  *			[NO LONGER SUPPORTED]
79  * (2)	V7 research:	has CBREAK, has ioctl, and has the tchars (TIOCSETC)
80  *			business to change start, stop, etc. chars.
81  * (3)	USG V2:		Basically like V6 but RAW mode is like V7 RAW.
82  *			[NO LONGER SUPPORTED]
83  * (4)	USG V3:		equivalent to V7 but totally incompatible.
84  * (5)  Berkeley 4BSD:	has ltchars in addition to all of V7.
85  *
86  * The following attempts to decide what we are on, and declare
87  * some variables in the appropriate format.  The wierd looking one (ttymode)
88  * is the thing we pass to sTTY and family to turn "RAW" mode on or off
89  * when we go into or out of visual mode.  In V7/4BSD it's just the flags word
90  * to stty.  In USG V3 it's the whole tty structure.
91  */
92 #ifdef	USG			/* USG V3 */
93   var	struct	termios tty;	/* Use this one structure to change modes */
94   typedef	struct termios ttymode;	/* Mode to contain tty flags */
95 
96 #else				/* All others */
97   var	struct	sgttyb tty;	/* Always stty/gtty using this one structure */
98   typedef	int ttymode;	/* Mode to contain tty flags */
99 #ifdef 	TIOCSETC		/* V7 */
100    var	struct	tchars ottyc, nttyc;	/* For V7 character masking */
101 #endif
102 #ifdef		TIOCLGET	/* Berkeley 4BSD */
103    var	struct	ltchars olttyc, nlttyc;	/* More of tchars style stuff */
104 #endif
105 
106 #endif
107 
108 var	ttymode	normf;		/* Restore tty flags to this (someday) */
109 var	bool	normtty;	/* Have to restore normal mode from normf */
110 
111 ttymode ostart(), setty(), unixex();
112 
113 var	short	costCM;	/* # chars to output a typical cursor_address, with padding etc. */
114 var	short	costSR;	/* likewise for scroll reverse */
115 var	short	costAL;	/* likewise for insert line */
116 var	short	costDP;	/* likewise for parm_down_cursor */
117 var	short	costLP;	/* likewise for parm_left_cursor */
118 var	short	costRP;	/* likewise for parm_right_cursor */
119 var	short	costCE;	/* likewise for clear to end of line */
120 var	short	costCD;	/* likewise for clear to end of display */
121 
122 #ifdef VMUNIX
123 #define MAXNOMACS	128	/* max number of macros of each kind */
124 #define MAXCHARMACS	2048	/* max # of chars total in macros */
125 #else
126 #define MAXNOMACS	32	/* max number of macros of each kind */
127 #define MAXCHARMACS	512	/* max # of chars total in macros */
128 #endif
129 struct maps {
130 	unsigned char *cap;	/* pressing button that sends this.. */
131 	unsigned char *mapto;	/* .. maps to this string */
132 	unsigned char *descr;	/* legible description of key */
133 };
134 var	struct maps arrows[MAXNOMACS];	/* macro defs - 1st 5 built in */
135 var	struct maps immacs[MAXNOMACS];	/* for while in insert mode */
136 var	struct maps abbrevs[MAXNOMACS];	/* for word abbreviations */
137 var	int 	abbrepcnt;		/* Repeating an abbreviation */
138 var	int	ldisc;			/* line discipline for ucb tty driver */
139 var	unsigned char	mapspace[MAXCHARMACS];
140 var	unsigned char	*msnext;	/* next free location in mapspace */
141 var	int	maphopcnt;	/* check for infinite mapping loops */
142 var	bool	anyabbrs;	/* true if abbr or unabbr has been done */
143 var	unsigned char	ttynbuf[20];	/* result of ttyname() */
144 var	int	ttymesg;	/* original mode of users tty */
145 
146 #ifdef XPG4
147 /*
148  * For POSIX.2, we need to make $LINES and $COLUMNS override whatever the
149  * system thinks are the appropriate real values.  The points of support
150  * for this feature lie scattered about in the fossil record, so we
151  * expose them to the World.
152  */
153 
154 var int envlines;
155 var int envcolumns;
156 var int oldlines;
157 var int oldcolumns;
158 #endif /* XPG4 */
159