1: /* Copyright (c) 1979 Regents of the University of California */ 2: /* 3: * Capabilities from termcap 4: * 5: * The description of terminals is a difficult business, and we only 6: * attempt to summarize the capabilities here; for a full description 7: * see the paper describing termcap. 8: * 9: * Capabilities from termcap are of three kinds - string valued options, 10: * numeric valued options, and boolean options. The string valued options 11: * are the most complicated, since they may include padding information, 12: * which we describe now. 13: * 14: * Intelligent terminals often require padding on intelligent operations 15: * at high (and sometimes even low) speed. This is specified by 16: * a number before the string in the capability, and has meaning for the 17: * capabilities which have a P at the front of their comment. 18: * This normally is a number of milliseconds to pad the operation. 19: * In the current system which has no true programmible delays, we 20: * do this by sending a sequence of pad characters (normally nulls, but 21: * specifiable as "pc"). In some cases, the pad is better computed 22: * as some number of milliseconds times the number of affected lines 23: * (to bottom of screen usually, except when terminals have insert modes 24: * which will shift several lines.) This is specified as '12*' e.g. 25: * before the capability to say 12 milliseconds per affected whatever 26: * (currently always line). Capabilities where this makes sense say P*. 27: */ 28: char tspace[256]; /* Space for capability strings */ 29: char *aoftspace; /* Address of tspace for relocation */ 30: 31: char *AL; /* P* Add new blank line */ 32: char *BC; /* Back cursor */ 33: char *BT; /* P Back tab */ 34: char *CD; /* P* Clear to end of display */ 35: char *CE; /* P Clear to end of line */ 36: char *CL; /* P* Clear screen */ 37: char *CM; /* P Cursor motion */ 38: char *xCR; /* P Carriage return */ 39: char *DC; /* P* Delete character */ 40: char *DL; /* P* Delete line sequence */ 41: char *DM; /* Delete mode (enter) */ 42: char *DO; /* Down line sequence */ 43: char *ED; /* End delete mode */ 44: char *EI; /* End insert mode */ 45: char *HO; /* Home cursor */ 46: char *IC; /* P Insert character */ 47: char *IM; /* Insert mode (give as ':im=:' if 'ic' */ 48: char *IP; /* P* Insert pad after char ins'd using IM+IE */ 49: char *LL; /* Quick to last line, column 0 */ 50: char *MA; /* Control character map for cmd mode */ 51: char *ND; /* Non-destructive space */ 52: char *xNL; /* Line feed (new line) */ 53: char PC; /* Pad character */ 54: char *SE; /* Standout end (may leave space) */ 55: char *SF; /* P Scroll forwards */ 56: char *SO; /* Stand out begin (may leave space) */ 57: char *SR; /* P Scroll backwards */ 58: char *TA; /* P Tab (other than ^I or with padding) */ 59: char *TE; /* Terminal end sequence */ 60: char *TI; /* Terminal initial sequence */ 61: char *UP; /* Upline */ 62: char *VB; /* Visible bell */ 63: char *VE; /* Visual end sequence */ 64: char *VS; /* Visual start sequence */ 65: bool AM; /* Automatic margins */ 66: bool BS; /* Backspace works */ 67: bool CA; /* Cursor addressible */ 68: bool DA; /* Display may be retained above */ 69: bool DB; /* Display may be retained below */ 70: bool EO; /* Can erase overstrikes with ' ' */ 71: bool GT; /* Gtty indicates tabs */ 72: bool HC; /* Hard copy terminal */ 73: bool HZ; /* Hazeltine ~ braindamage */ 74: bool IN; /* Insert-null blessing */ 75: bool MI; /* can move in insert mode */ 76: bool NC; /* No Cr - \r snds \r\n then eats \n (dm2500) */ 77: bool NS; /* No scroll - linefeed at bottom won't scroll */ 78: bool OS; /* Overstrike works */ 79: bool UL; /* Underlining works even though !os */ 80: bool XB; /* Beehive superbee f1=esc, f2=^C */ 81: bool XN; /* A newline gets eaten after wrap (concept) */ 82: bool XT; /* Tabs are destructive */ 83: bool XX; /* Tektronix 4025/4027 */ 84: /* X? is reserved for severely nauseous glitches */ 85: /* If there are enough of these we may need bit masks! */ 86: 87: /* 88: * From the tty modes... 89: */ 90: bool NONL; /* Terminal can't hack linefeeds doing a CR */ 91: bool UPPERCASE; /* Ick! */ 92: short LINES; /* Number of lines on screen */ 93: short COLUMNS; 94: short OCOLUMNS; /* Save COLUMNS for a hack in open mode */ 95: 96: short outcol; /* Where the cursor is */ 97: short outline; 98: 99: short destcol; /* Where the cursor should be */ 100: short destline; 101: 102: /* 103: * There are several kinds of tty drivers to contend with. These include: 104: * (1) V6: no CBREAK, no ioctl. (Include PWB V1 here.) 105: * (2) V7 research: has CBREAK, has ioctl, and has the tchars (TIOCSETC) 106: * business to change start, stop, etc. chars. 107: * (3) USG V2: Basically like V6 but RAW mode is like V7 RAW. 108: * (We treat it as V6.) 109: * (4) USG V3: equivalent to V7 but totally incompatible. 110: * 111: * The following attempts to decide what we are on, and declare 112: * some variables in the appropriate format. The wierd looking one (ttymode) 113: * is the thing we pass to sTTY and family to turn "RAW" mode on or off 114: * when we go into or out of visual mode. In V7/V6 it's just the flags word 115: * to stty. In USG V3 it's the whole tty structure. 116: */ 117: #ifdef USG3TTY 118: struct termio tty; /* Use this one structure to change modes */ 119: typedef struct termio ttymode; /* Mode to contain tty flags */ 120: #else 121: struct sgttyb tty; /* Always stty/gtty using this one structure */ 122: typedef int ttymode; /* Mode to contain tty flags */ 123: # ifdef TIOCSETC 124: struct tchars ottyc, nttyc; /* For V7 character masking */ 125: # endif 126: #endif 127: ttymode normf; /* Restore tty flags to this (someday) */ 128: bool normtty; /* Have to restor normal mode from normf */ 129: 130: ttymode ostart(), setty(), unixex(); 131: 132: short WBOT; 133: short WECHO; 134: 135: short costCM;