10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 50Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 60Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 70Sstevel@tonic-gate * with the License. 80Sstevel@tonic-gate * 90Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 100Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 110Sstevel@tonic-gate * See the License for the specific language governing permissions 120Sstevel@tonic-gate * and limitations under the License. 130Sstevel@tonic-gate * 140Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 150Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 160Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 170Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 180Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 190Sstevel@tonic-gate * 200Sstevel@tonic-gate * CDDL HEADER END 210Sstevel@tonic-gate */ 220Sstevel@tonic-gate /* 23*802Scf46844 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 240Sstevel@tonic-gate * Use is subject to license terms. 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 270Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 280Sstevel@tonic-gate /* All Rights Reserved */ 290Sstevel@tonic-gate 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* Copyright (c) 1981 Regents of the University of California */ 320Sstevel@tonic-gate 33*802Scf46844 #ifndef _EX_TTY_H 34*802Scf46844 #define _EX_TTY_H 35*802Scf46844 360Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 370Sstevel@tonic-gate 38*802Scf46844 #ifdef __cplusplus 39*802Scf46844 extern "C" { 40*802Scf46844 #endif 41*802Scf46844 420Sstevel@tonic-gate /* 430Sstevel@tonic-gate * Capabilities from termcap 440Sstevel@tonic-gate * 450Sstevel@tonic-gate * The description of terminals is a difficult business, and we only 460Sstevel@tonic-gate * attempt to summarize the capabilities here; for a full description 470Sstevel@tonic-gate * see the paper describing termcap. 480Sstevel@tonic-gate * 490Sstevel@tonic-gate * Capabilities from termcap are of three kinds - string valued options, 500Sstevel@tonic-gate * numeric valued options, and boolean options. The string valued options 510Sstevel@tonic-gate * are the most complicated, since they may include padding information, 520Sstevel@tonic-gate * which we describe now. 530Sstevel@tonic-gate * 540Sstevel@tonic-gate * Intelligent terminals often require padding on intelligent operations 550Sstevel@tonic-gate * at high (and sometimes even low) speed. This is specified by 560Sstevel@tonic-gate * a number before the string in the capability, and has meaning for the 570Sstevel@tonic-gate * capabilities which have a P at the front of their comment. 580Sstevel@tonic-gate * This normally is a number of milliseconds to pad the operation. 590Sstevel@tonic-gate * In the current system which has no true programmable delays, we 600Sstevel@tonic-gate * do this by sending a sequence of pad characters (normally nulls, but 610Sstevel@tonic-gate * specifiable as "pc"). In some cases, the pad is better computed 620Sstevel@tonic-gate * as some number of milliseconds times the number of affected lines 630Sstevel@tonic-gate * (to bottom of screen usually, except when terminals have insert modes 640Sstevel@tonic-gate * which will shift several lines.) This is specified as '12*' e.g. 650Sstevel@tonic-gate * before the capability to say 12 milliseconds per affected whatever 660Sstevel@tonic-gate * (currently always line). Capabilities where this makes sense say P*. 670Sstevel@tonic-gate */ 680Sstevel@tonic-gate 690Sstevel@tonic-gate /* 700Sstevel@tonic-gate * From the tty modes... 710Sstevel@tonic-gate */ 720Sstevel@tonic-gate var bool NONL; /* Terminal can't hack linefeeds doing a CR */ 730Sstevel@tonic-gate var bool UPPERCASE; 740Sstevel@tonic-gate var short OCOLUMNS; /* Save columns for a hack in open mode */ 750Sstevel@tonic-gate 760Sstevel@tonic-gate var short outcol; /* Where the cursor is */ 770Sstevel@tonic-gate var short outline; 780Sstevel@tonic-gate 790Sstevel@tonic-gate var short destcol; /* Where the cursor should be */ 800Sstevel@tonic-gate var short destline; 810Sstevel@tonic-gate 820Sstevel@tonic-gate /* 830Sstevel@tonic-gate * There are several kinds of tty drivers to contend with. These include: 840Sstevel@tonic-gate * (1) V6: no CBREAK, no ioctl. (Include PWB V1 here). 850Sstevel@tonic-gate * [NO LONGER SUPPORTED] 860Sstevel@tonic-gate * (2) V7 research: has CBREAK, has ioctl, and has the tchars (TIOCSETC) 870Sstevel@tonic-gate * business to change start, stop, etc. chars. 880Sstevel@tonic-gate * (3) USG V2: Basically like V6 but RAW mode is like V7 RAW. 890Sstevel@tonic-gate * [NO LONGER SUPPORTED] 900Sstevel@tonic-gate * (4) USG V3: equivalent to V7 but totally incompatible. 910Sstevel@tonic-gate * (5) Berkeley 4BSD: has ltchars in addition to all of V7. 920Sstevel@tonic-gate * 930Sstevel@tonic-gate * The following attempts to decide what we are on, and declare 940Sstevel@tonic-gate * some variables in the appropriate format. The wierd looking one (ttymode) 950Sstevel@tonic-gate * is the thing we pass to sTTY and family to turn "RAW" mode on or off 960Sstevel@tonic-gate * when we go into or out of visual mode. In V7/4BSD it's just the flags word 970Sstevel@tonic-gate * to stty. In USG V3 it's the whole tty structure. 980Sstevel@tonic-gate */ 990Sstevel@tonic-gate #ifdef USG /* USG V3 */ 1000Sstevel@tonic-gate var struct termios tty; /* Use this one structure to change modes */ 1010Sstevel@tonic-gate typedef struct termios ttymode; /* Mode to contain tty flags */ 1020Sstevel@tonic-gate 1030Sstevel@tonic-gate #else /* All others */ 1040Sstevel@tonic-gate var struct sgttyb tty; /* Always stty/gtty using this one structure */ 1050Sstevel@tonic-gate typedef int ttymode; /* Mode to contain tty flags */ 1060Sstevel@tonic-gate #ifdef TIOCSETC /* V7 */ 1070Sstevel@tonic-gate var struct tchars ottyc, nttyc; /* For V7 character masking */ 1080Sstevel@tonic-gate #endif 1090Sstevel@tonic-gate #ifdef TIOCLGET /* Berkeley 4BSD */ 1100Sstevel@tonic-gate var struct ltchars olttyc, nlttyc; /* More of tchars style stuff */ 1110Sstevel@tonic-gate #endif 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate #endif 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate var ttymode normf; /* Restore tty flags to this (someday) */ 1160Sstevel@tonic-gate var bool normtty; /* Have to restore normal mode from normf */ 1170Sstevel@tonic-gate 1180Sstevel@tonic-gate ttymode ostart(), setty(), unixex(); 119*802Scf46844 void putpad(unsigned char *cp); 120*802Scf46844 void pstart(void); 121*802Scf46844 void pstop(void); 122*802Scf46844 void tostart(void); 123*802Scf46844 void ttcharoff(void); 124*802Scf46844 void tostop(void); 125*802Scf46844 void normal(ttymode); 126*802Scf46844 void sTTY(int); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate var short costCM; /* # chars to output a typical cursor_address, with padding etc. */ 1290Sstevel@tonic-gate var short costSR; /* likewise for scroll reverse */ 1300Sstevel@tonic-gate var short costAL; /* likewise for insert line */ 1310Sstevel@tonic-gate var short costDP; /* likewise for parm_down_cursor */ 1320Sstevel@tonic-gate var short costLP; /* likewise for parm_left_cursor */ 1330Sstevel@tonic-gate var short costRP; /* likewise for parm_right_cursor */ 1340Sstevel@tonic-gate var short costCE; /* likewise for clear to end of line */ 1350Sstevel@tonic-gate var short costCD; /* likewise for clear to end of display */ 1360Sstevel@tonic-gate 1370Sstevel@tonic-gate #ifdef VMUNIX 1380Sstevel@tonic-gate #define MAXNOMACS 128 /* max number of macros of each kind */ 1390Sstevel@tonic-gate #define MAXCHARMACS 2048 /* max # of chars total in macros */ 1400Sstevel@tonic-gate #else 1410Sstevel@tonic-gate #define MAXNOMACS 32 /* max number of macros of each kind */ 1420Sstevel@tonic-gate #define MAXCHARMACS 512 /* max # of chars total in macros */ 1430Sstevel@tonic-gate #endif 1440Sstevel@tonic-gate struct maps { 1450Sstevel@tonic-gate unsigned char *cap; /* pressing button that sends this.. */ 1460Sstevel@tonic-gate unsigned char *mapto; /* .. maps to this string */ 1470Sstevel@tonic-gate unsigned char *descr; /* legible description of key */ 1480Sstevel@tonic-gate }; 149*802Scf46844 void kpadd(struct maps *, unsigned char *, unsigned char *, unsigned char *); 1500Sstevel@tonic-gate var struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */ 1510Sstevel@tonic-gate var struct maps immacs[MAXNOMACS]; /* for while in insert mode */ 1520Sstevel@tonic-gate var struct maps abbrevs[MAXNOMACS]; /* for word abbreviations */ 1530Sstevel@tonic-gate var int abbrepcnt; /* Repeating an abbreviation */ 1540Sstevel@tonic-gate var int ldisc; /* line discipline for ucb tty driver */ 1550Sstevel@tonic-gate var unsigned char mapspace[MAXCHARMACS]; 1560Sstevel@tonic-gate var unsigned char *msnext; /* next free location in mapspace */ 1570Sstevel@tonic-gate var int maphopcnt; /* check for infinite mapping loops */ 1580Sstevel@tonic-gate var bool anyabbrs; /* true if abbr or unabbr has been done */ 1590Sstevel@tonic-gate var unsigned char ttynbuf[20]; /* result of ttyname() */ 1600Sstevel@tonic-gate var int ttymesg; /* original mode of users tty */ 1610Sstevel@tonic-gate 1620Sstevel@tonic-gate #ifdef XPG4 1630Sstevel@tonic-gate /* 1640Sstevel@tonic-gate * For POSIX.2, we need to make $LINES and $COLUMNS override whatever the 1650Sstevel@tonic-gate * system thinks are the appropriate real values. The points of support 1660Sstevel@tonic-gate * for this feature lie scattered about in the fossil record, so we 1670Sstevel@tonic-gate * expose them to the World. 1680Sstevel@tonic-gate */ 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate var int envlines; 1710Sstevel@tonic-gate var int envcolumns; 1720Sstevel@tonic-gate var int oldlines; 1730Sstevel@tonic-gate var int oldcolumns; 1740Sstevel@tonic-gate #endif /* XPG4 */ 175*802Scf46844 176*802Scf46844 #ifdef __cplusplus 177*802Scf46844 } 178*802Scf46844 #endif 179*802Scf46844 180*802Scf46844 #endif /* _EX_TTY_H */ 181