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 2005 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 #ifndef _EX_TTY_H 34 #define _EX_TTY_H 35 36 #ifdef __cplusplus 37 extern "C" { 38 #endif 39 40 /* 41 * Capabilities from termcap 42 * 43 * The description of terminals is a difficult business, and we only 44 * attempt to summarize the capabilities here; for a full description 45 * see the paper describing termcap. 46 * 47 * Capabilities from termcap are of three kinds - string valued options, 48 * numeric valued options, and boolean options. The string valued options 49 * are the most complicated, since they may include padding information, 50 * which we describe now. 51 * 52 * Intelligent terminals often require padding on intelligent operations 53 * at high (and sometimes even low) speed. This is specified by 54 * a number before the string in the capability, and has meaning for the 55 * capabilities which have a P at the front of their comment. 56 * This normally is a number of milliseconds to pad the operation. 57 * In the current system which has no true programmable delays, we 58 * do this by sending a sequence of pad characters (normally nulls, but 59 * specifiable as "pc"). In some cases, the pad is better computed 60 * as some number of milliseconds times the number of affected lines 61 * (to bottom of screen usually, except when terminals have insert modes 62 * which will shift several lines.) This is specified as '12*' e.g. 63 * before the capability to say 12 milliseconds per affected whatever 64 * (currently always line). Capabilities where this makes sense say P*. 65 */ 66 67 /* 68 * From the tty modes... 69 */ 70 var bool NONL; /* Terminal can't hack linefeeds doing a CR */ 71 var bool UPPERCASE; 72 var short OCOLUMNS; /* Save columns for a hack in open mode */ 73 74 var short outcol; /* Where the cursor is */ 75 var short outline; 76 77 var short destcol; /* Where the cursor should be */ 78 var short destline; 79 80 /* 81 * There are several kinds of tty drivers to contend with. These include: 82 * (1) V6: no CBREAK, no ioctl. (Include PWB V1 here). 83 * [NO LONGER SUPPORTED] 84 * (2) V7 research: has CBREAK, has ioctl, and has the tchars (TIOCSETC) 85 * business to change start, stop, etc. chars. 86 * (3) USG V2: Basically like V6 but RAW mode is like V7 RAW. 87 * [NO LONGER SUPPORTED] 88 * (4) USG V3: equivalent to V7 but totally incompatible. 89 * (5) Berkeley 4BSD: has ltchars in addition to all of V7. 90 * 91 * The following attempts to decide what we are on, and declare 92 * some variables in the appropriate format. The wierd looking one (ttymode) 93 * is the thing we pass to sTTY and family to turn "RAW" mode on or off 94 * when we go into or out of visual mode. In V7/4BSD it's just the flags word 95 * to stty. In USG V3 it's the whole tty structure. 96 */ 97 #ifdef USG /* USG V3 */ 98 var struct termios tty; /* Use this one structure to change modes */ 99 typedef struct termios ttymode; /* Mode to contain tty flags */ 100 101 #else /* All others */ 102 var struct sgttyb tty; /* Always stty/gtty using this one structure */ 103 typedef int ttymode; /* Mode to contain tty flags */ 104 #ifdef TIOCSETC /* V7 */ 105 var struct tchars ottyc, nttyc; /* For V7 character masking */ 106 #endif 107 #ifdef TIOCLGET /* Berkeley 4BSD */ 108 var struct ltchars olttyc, nlttyc; /* More of tchars style stuff */ 109 #endif 110 111 #endif 112 113 var ttymode normf; /* Restore tty flags to this (someday) */ 114 var bool normtty; /* Have to restore normal mode from normf */ 115 116 ttymode ostart(), setty(), unixex(); 117 void putpad(unsigned char *cp); 118 void pstart(void); 119 void pstop(void); 120 void tostart(void); 121 void ttcharoff(void); 122 void tostop(void); 123 void normal(ttymode); 124 void sTTY(int); 125 126 var short costCM; /* # chars to output a typical cursor_address, with padding etc. */ 127 var short costSR; /* likewise for scroll reverse */ 128 var short costAL; /* likewise for insert line */ 129 var short costDP; /* likewise for parm_down_cursor */ 130 var short costLP; /* likewise for parm_left_cursor */ 131 var short costRP; /* likewise for parm_right_cursor */ 132 var short costCE; /* likewise for clear to end of line */ 133 var short costCD; /* likewise for clear to end of display */ 134 135 #ifdef VMUNIX 136 #define MAXNOMACS 128 /* max number of macros of each kind */ 137 #define MAXCHARMACS 2048 /* max # of chars total in macros */ 138 #else 139 #define MAXNOMACS 32 /* max number of macros of each kind */ 140 #define MAXCHARMACS 512 /* max # of chars total in macros */ 141 #endif 142 struct maps { 143 unsigned char *cap; /* pressing button that sends this.. */ 144 unsigned char *mapto; /* .. maps to this string */ 145 unsigned char *descr; /* legible description of key */ 146 }; 147 void kpadd(struct maps *, unsigned char *, unsigned char *, unsigned char *); 148 var struct maps arrows[MAXNOMACS]; /* macro defs - 1st 5 built in */ 149 var struct maps immacs[MAXNOMACS]; /* for while in insert mode */ 150 var struct maps abbrevs[MAXNOMACS]; /* for word abbreviations */ 151 var int abbrepcnt; /* Repeating an abbreviation */ 152 var int ldisc; /* line discipline for ucb tty driver */ 153 var unsigned char mapspace[MAXCHARMACS]; 154 var unsigned char *msnext; /* next free location in mapspace */ 155 var int maphopcnt; /* check for infinite mapping loops */ 156 var bool anyabbrs; /* true if abbr or unabbr has been done */ 157 var unsigned char ttynbuf[20]; /* result of ttyname() */ 158 var int ttymesg; /* original mode of users tty */ 159 160 #ifdef XPG4 161 /* 162 * For POSIX.2, we need to make $LINES and $COLUMNS override whatever the 163 * system thinks are the appropriate real values. The points of support 164 * for this feature lie scattered about in the fossil record, so we 165 * expose them to the World. 166 */ 167 168 var int envlines; 169 var int envcolumns; 170 var int oldlines; 171 var int oldcolumns; 172 #endif /* XPG4 */ 173 174 #ifdef __cplusplus 175 } 176 #endif 177 178 #endif /* _EX_TTY_H */ 179