xref: /titanic_41/usr/src/cmd/vi/port/ex_tty.h (revision f6db9f272f0061301cfaa1c0001b7d636eae31f4)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
23*f6db9f27Scf46844  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
287c478bd9Sstevel@tonic-gate /*	  All Rights Reserved  	*/
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */
327c478bd9Sstevel@tonic-gate 
33*f6db9f27Scf46844 #ifndef _EX_TTY_H
34*f6db9f27Scf46844 #define	_EX_TTY_H
35*f6db9f27Scf46844 
367c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
377c478bd9Sstevel@tonic-gate 
38*f6db9f27Scf46844 #ifdef __cplusplus
39*f6db9f27Scf46844 extern "C" {
40*f6db9f27Scf46844 #endif
41*f6db9f27Scf46844 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * Capabilities from termcap
447c478bd9Sstevel@tonic-gate  *
457c478bd9Sstevel@tonic-gate  * The description of terminals is a difficult business, and we only
467c478bd9Sstevel@tonic-gate  * attempt to summarize the capabilities here;  for a full description
477c478bd9Sstevel@tonic-gate  * see the paper describing termcap.
487c478bd9Sstevel@tonic-gate  *
497c478bd9Sstevel@tonic-gate  * Capabilities from termcap are of three kinds - string valued options,
507c478bd9Sstevel@tonic-gate  * numeric valued options, and boolean options.  The string valued options
517c478bd9Sstevel@tonic-gate  * are the most complicated, since they may include padding information,
527c478bd9Sstevel@tonic-gate  * which we describe now.
537c478bd9Sstevel@tonic-gate  *
547c478bd9Sstevel@tonic-gate  * Intelligent terminals often require padding on intelligent operations
557c478bd9Sstevel@tonic-gate  * at high (and sometimes even low) speed.  This is specified by
567c478bd9Sstevel@tonic-gate  * a number before the string in the capability, and has meaning for the
577c478bd9Sstevel@tonic-gate  * capabilities which have a P at the front of their comment.
587c478bd9Sstevel@tonic-gate  * This normally is a number of milliseconds to pad the operation.
597c478bd9Sstevel@tonic-gate  * In the current system which has no true programmable delays, we
607c478bd9Sstevel@tonic-gate  * do this by sending a sequence of pad characters (normally nulls, but
617c478bd9Sstevel@tonic-gate  * specifiable as "pc").  In some cases, the pad is better computed
627c478bd9Sstevel@tonic-gate  * as some number of milliseconds times the number of affected lines
637c478bd9Sstevel@tonic-gate  * (to bottom of screen usually, except when terminals have insert modes
647c478bd9Sstevel@tonic-gate  * which will shift several lines.)  This is specified as '12*' e.g.
657c478bd9Sstevel@tonic-gate  * before the capability to say 12 milliseconds per affected whatever
667c478bd9Sstevel@tonic-gate  * (currently always line).  Capabilities where this makes sense say P*.
677c478bd9Sstevel@tonic-gate  */
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate /*
707c478bd9Sstevel@tonic-gate  * From the tty modes...
717c478bd9Sstevel@tonic-gate  */
727c478bd9Sstevel@tonic-gate var	bool	NONL;		/* Terminal can't hack linefeeds doing a CR */
737c478bd9Sstevel@tonic-gate var	bool	UPPERCASE;
747c478bd9Sstevel@tonic-gate var	short	OCOLUMNS;	/* Save columns for a hack in open mode */
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate var	short	outcol;		/* Where the cursor is */
777c478bd9Sstevel@tonic-gate var	short	outline;
787c478bd9Sstevel@tonic-gate 
797c478bd9Sstevel@tonic-gate var	short	destcol;	/* Where the cursor should be */
807c478bd9Sstevel@tonic-gate var	short	destline;
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate /*
837c478bd9Sstevel@tonic-gate  * There are several kinds of tty drivers to contend with.  These include:
847c478bd9Sstevel@tonic-gate  * (1)	V6:		no CBREAK, no ioctl.  (Include PWB V1 here).
857c478bd9Sstevel@tonic-gate  *			[NO LONGER SUPPORTED]
867c478bd9Sstevel@tonic-gate  * (2)	V7 research:	has CBREAK, has ioctl, and has the tchars (TIOCSETC)
877c478bd9Sstevel@tonic-gate  *			business to change start, stop, etc. chars.
887c478bd9Sstevel@tonic-gate  * (3)	USG V2:		Basically like V6 but RAW mode is like V7 RAW.
897c478bd9Sstevel@tonic-gate  *			[NO LONGER SUPPORTED]
907c478bd9Sstevel@tonic-gate  * (4)	USG V3:		equivalent to V7 but totally incompatible.
917c478bd9Sstevel@tonic-gate  * (5)  Berkeley 4BSD:	has ltchars in addition to all of V7.
927c478bd9Sstevel@tonic-gate  *
937c478bd9Sstevel@tonic-gate  * The following attempts to decide what we are on, and declare
947c478bd9Sstevel@tonic-gate  * some variables in the appropriate format.  The wierd looking one (ttymode)
957c478bd9Sstevel@tonic-gate  * is the thing we pass to sTTY and family to turn "RAW" mode on or off
967c478bd9Sstevel@tonic-gate  * when we go into or out of visual mode.  In V7/4BSD it's just the flags word
977c478bd9Sstevel@tonic-gate  * to stty.  In USG V3 it's the whole tty structure.
987c478bd9Sstevel@tonic-gate  */
997c478bd9Sstevel@tonic-gate #ifdef	USG			/* USG V3 */
1007c478bd9Sstevel@tonic-gate   var	struct	termios tty;	/* Use this one structure to change modes */
1017c478bd9Sstevel@tonic-gate   typedef	struct termios ttymode;	/* Mode to contain tty flags */
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate #else				/* All others */
1047c478bd9Sstevel@tonic-gate   var	struct	sgttyb tty;	/* Always stty/gtty using this one structure */
1057c478bd9Sstevel@tonic-gate   typedef	int ttymode;	/* Mode to contain tty flags */
1067c478bd9Sstevel@tonic-gate #ifdef 	TIOCSETC		/* V7 */
1077c478bd9Sstevel@tonic-gate    var	struct	tchars ottyc, nttyc;	/* For V7 character masking */
1087c478bd9Sstevel@tonic-gate #endif
1097c478bd9Sstevel@tonic-gate #ifdef		TIOCLGET	/* Berkeley 4BSD */
1107c478bd9Sstevel@tonic-gate    var	struct	ltchars olttyc, nlttyc;	/* More of tchars style stuff */
1117c478bd9Sstevel@tonic-gate #endif
1127c478bd9Sstevel@tonic-gate 
1137c478bd9Sstevel@tonic-gate #endif
1147c478bd9Sstevel@tonic-gate 
1157c478bd9Sstevel@tonic-gate var	ttymode	normf;		/* Restore tty flags to this (someday) */
1167c478bd9Sstevel@tonic-gate var	bool	normtty;	/* Have to restore normal mode from normf */
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate ttymode ostart(), setty(), unixex();
119*f6db9f27Scf46844 void putpad(unsigned char *cp);
120*f6db9f27Scf46844 void pstart(void);
121*f6db9f27Scf46844 void pstop(void);
122*f6db9f27Scf46844 void tostart(void);
123*f6db9f27Scf46844 void ttcharoff(void);
124*f6db9f27Scf46844 void tostop(void);
125*f6db9f27Scf46844 void normal(ttymode);
126*f6db9f27Scf46844 void sTTY(int);
1277c478bd9Sstevel@tonic-gate 
1287c478bd9Sstevel@tonic-gate var	short	costCM;	/* # chars to output a typical cursor_address, with padding etc. */
1297c478bd9Sstevel@tonic-gate var	short	costSR;	/* likewise for scroll reverse */
1307c478bd9Sstevel@tonic-gate var	short	costAL;	/* likewise for insert line */
1317c478bd9Sstevel@tonic-gate var	short	costDP;	/* likewise for parm_down_cursor */
1327c478bd9Sstevel@tonic-gate var	short	costLP;	/* likewise for parm_left_cursor */
1337c478bd9Sstevel@tonic-gate var	short	costRP;	/* likewise for parm_right_cursor */
1347c478bd9Sstevel@tonic-gate var	short	costCE;	/* likewise for clear to end of line */
1357c478bd9Sstevel@tonic-gate var	short	costCD;	/* likewise for clear to end of display */
1367c478bd9Sstevel@tonic-gate 
1377c478bd9Sstevel@tonic-gate #ifdef VMUNIX
1387c478bd9Sstevel@tonic-gate #define MAXNOMACS	128	/* max number of macros of each kind */
1397c478bd9Sstevel@tonic-gate #define MAXCHARMACS	2048	/* max # of chars total in macros */
1407c478bd9Sstevel@tonic-gate #else
1417c478bd9Sstevel@tonic-gate #define MAXNOMACS	32	/* max number of macros of each kind */
1427c478bd9Sstevel@tonic-gate #define MAXCHARMACS	512	/* max # of chars total in macros */
1437c478bd9Sstevel@tonic-gate #endif
1447c478bd9Sstevel@tonic-gate struct maps {
1457c478bd9Sstevel@tonic-gate 	unsigned char *cap;	/* pressing button that sends this.. */
1467c478bd9Sstevel@tonic-gate 	unsigned char *mapto;	/* .. maps to this string */
1477c478bd9Sstevel@tonic-gate 	unsigned char *descr;	/* legible description of key */
1487c478bd9Sstevel@tonic-gate };
149*f6db9f27Scf46844 void kpadd(struct maps *, unsigned char *, unsigned char *, unsigned char *);
1507c478bd9Sstevel@tonic-gate var	struct maps arrows[MAXNOMACS];	/* macro defs - 1st 5 built in */
1517c478bd9Sstevel@tonic-gate var	struct maps immacs[MAXNOMACS];	/* for while in insert mode */
1527c478bd9Sstevel@tonic-gate var	struct maps abbrevs[MAXNOMACS];	/* for word abbreviations */
1537c478bd9Sstevel@tonic-gate var	int 	abbrepcnt;		/* Repeating an abbreviation */
1547c478bd9Sstevel@tonic-gate var	int	ldisc;			/* line discipline for ucb tty driver */
1557c478bd9Sstevel@tonic-gate var	unsigned char	mapspace[MAXCHARMACS];
1567c478bd9Sstevel@tonic-gate var	unsigned char	*msnext;	/* next free location in mapspace */
1577c478bd9Sstevel@tonic-gate var	int	maphopcnt;	/* check for infinite mapping loops */
1587c478bd9Sstevel@tonic-gate var	bool	anyabbrs;	/* true if abbr or unabbr has been done */
1597c478bd9Sstevel@tonic-gate var	unsigned char	ttynbuf[20];	/* result of ttyname() */
1607c478bd9Sstevel@tonic-gate var	int	ttymesg;	/* original mode of users tty */
1617c478bd9Sstevel@tonic-gate 
1627c478bd9Sstevel@tonic-gate #ifdef XPG4
1637c478bd9Sstevel@tonic-gate /*
1647c478bd9Sstevel@tonic-gate  * For POSIX.2, we need to make $LINES and $COLUMNS override whatever the
1657c478bd9Sstevel@tonic-gate  * system thinks are the appropriate real values.  The points of support
1667c478bd9Sstevel@tonic-gate  * for this feature lie scattered about in the fossil record, so we
1677c478bd9Sstevel@tonic-gate  * expose them to the World.
1687c478bd9Sstevel@tonic-gate  */
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate var int envlines;
1717c478bd9Sstevel@tonic-gate var int envcolumns;
1727c478bd9Sstevel@tonic-gate var int oldlines;
1737c478bd9Sstevel@tonic-gate var int oldcolumns;
1747c478bd9Sstevel@tonic-gate #endif /* XPG4 */
175*f6db9f27Scf46844 
176*f6db9f27Scf46844 #ifdef __cplusplus
177*f6db9f27Scf46844 }
178*f6db9f27Scf46844 #endif
179*f6db9f27Scf46844 
180*f6db9f27Scf46844 #endif /* _EX_TTY_H */
181