|
|
1.1 ! root 1: /************************************************************************* ! 2: * This program is copyright (C) 1985, 1986 by Jonathan Payne. It is * ! 3: * provided to you without charge for use only on a licensed Unix * ! 4: * system. You may copy JOVE provided that this notice is included with * ! 5: * the copy. You may not sell copies of this program or versions * ! 6: * modified for use on microcomputer systems, unless the copies are * ! 7: * included with a Unix system distribution and the source is provided. * ! 8: *************************************************************************/ ! 9: ! 10: #include "jove.h" ! 11: #include <errno.h> ! 12: #ifdef SYSV ! 13: # include <termio.h> ! 14: #else ! 15: # include <sgtty.h> ! 16: #endif SYSV ! 17: ! 18: #ifdef IPROCS ! 19: # include <signal.h> ! 20: #endif ! 21: ! 22: /* Termcap definitions */ ! 23: ! 24: char *UP, ! 25: *CS, ! 26: *SO, ! 27: *SE, ! 28: *CM, ! 29: *CL, ! 30: *CE, ! 31: *HO, ! 32: *AL, ! 33: *DL, ! 34: *VS, ! 35: *VE, ! 36: *KS, ! 37: *KE, ! 38: *TI, ! 39: *TE, ! 40: *IC, ! 41: *DC, ! 42: *IM, ! 43: *EI, ! 44: *LL, ! 45: *BC, ! 46: *M_IC, /* Insert char with arg */ ! 47: *M_DC, /* Delete char with arg */ ! 48: *M_AL, /* Insert line with arg */ ! 49: *M_DL, /* Delete line with arg */ ! 50: *SF, /* Scroll forward */ ! 51: *SR, ! 52: *SP, /* Send Cursor Position */ ! 53: #ifdef LSRHS ! 54: *RS, /* Reverse video start */ ! 55: *RE, /* Reverse end */ ! 56: #endif ! 57: *VB, ! 58: *IP, /* insert pad after character inserted */ ! 59: *lPC; ! 60: ! 61: int LI, ! 62: ILI, /* Internal lines, i.e., 23 of LI is 24. */ ! 63: CO, ! 64: ! 65: UL, ! 66: MI, ! 67: SG, /* number of magic cookies left by SO and SE */ ! 68: XS, /* whether standout is braindamaged */ ! 69: ! 70: TABS, ! 71: UPlen, ! 72: HOlen, ! 73: LLlen; ! 74: ! 75: int ospeed; ! 76: extern char PC; ! 77: ! 78: static char tspace[256]; ! 79: ! 80: /* The ordering of ts and meas must agree !! */ ! 81: #ifdef LSRHS ! 82: static char *ts="vsvealdlspcssosecmclcehoupbcicimdceillsfsrvbksketiteALDLICDCrsrepcip"; ! 83: static char **meas[] = { ! 84: &VS, &VE, &AL, &DL, &SP, &CS, &SO, &SE, ! 85: &CM, &CL, &CE, &HO, &UP, &BC, &IC, &IM, ! 86: &DC, &EI, &LL, &SF, &SR, &VB, &KS, &KE, ! 87: &TI, &TE, &M_AL, &M_DL, &M_IC, &M_DC, ! 88: &RS, &RE, &lPC, &IP, 0 ! 89: }; ! 90: #else ! 91: static char *ts="vsvealdlspcssosecmclcehoupbcicimdceillsfsrvbksketiteALDLICDCpcip"; ! 92: static char **meas[] = { ! 93: &VS, &VE, &AL, &DL, &SP, &CS, &SO, &SE, ! 94: &CM, &CL, &CE, &HO, &UP, &BC, &IC, &IM, ! 95: &DC, &EI, &LL, &SF, &SR, &VB, &KS, &KE, ! 96: &TI, &TE, &M_AL, &M_DL, &M_IC, &M_DC, ! 97: &lPC, &IP, 0 ! 98: }; ! 99: #endif ! 100: ! 101: static ! 102: gets(buf) ! 103: char *buf; ! 104: { ! 105: buf[read(0, buf, 12) - 1] = 0; ! 106: } ! 107: ! 108: /* VARARGS1 */ ! 109: ! 110: static ! 111: TermError(fmt, a) ! 112: char *fmt; ! 113: { ! 114: printf(fmt, a); ! 115: _exit(1); ! 116: } ! 117: ! 118: getTERM() ! 119: { ! 120: char *getenv(); ! 121: char termbuf[13], ! 122: *termname = 0, ! 123: *termp = tspace, ! 124: tbuff[2048]; /* Good grief! */ ! 125: int i; ! 126: ! 127: termname = getenv("TERM"); ! 128: if (termname == 0) { ! 129: putstr("Enter terminal name: "); ! 130: gets(termbuf); ! 131: if (termbuf[0] == 0) ! 132: TermError(NullStr); ! 133: ! 134: termname = termbuf; ! 135: } ! 136: ! 137: if (tgetent(tbuff, termname) < 1) ! 138: TermError("[\"%s\" unknown terminal type?]", termname); ! 139: ! 140: if ((CO = tgetnum("co")) == -1) ! 141: TermError("columns?"); ! 142: ! 143: if ((LI = tgetnum("li")) == -1) ! 144: TermError("lines?"); ! 145: ! 146: if ((SG = tgetnum("sg")) == -1) ! 147: SG = 0; /* Used for mode line only */ ! 148: ! 149: if ((XS = tgetflag("xs")) == -1) ! 150: XS = 0; /* Used for mode line only */ ! 151: ! 152: for (i = 0; meas[i]; i++) { ! 153: *(meas[i]) = (char *) tgetstr(ts, &termp); ! 154: ts += 2; ! 155: } ! 156: if (lPC) ! 157: PC = *lPC; ! 158: if (XS) ! 159: SO = SE = 0; ! 160: ! 161: if (CS && !SR) ! 162: CS = SR = SF = 0; ! 163: ! 164: if (CS && !SF) ! 165: SF = "\n"; ! 166: ! 167: if (IM && (*IM == 0)) ! 168: IM = 0; ! 169: else ! 170: MI = tgetflag("mi"); ! 171: ! 172: UL = tgetflag("ul"); ! 173: ! 174: #ifdef LSRHS /* We, at the high school, are the only ones who ! 175: do SO right in termcap, but unfortunately the ! 176: right SO doesn't look as good with modelines. */ ! 177: if (RS) ! 178: SO = RS; ! 179: if (RE) ! 180: SE = RE; ! 181: /* I only ever use SO for the modeline anyway. */ ! 182: ! 183: /* SO is really BOLDFACE! Why is LS always right and the rest of the ! 184: world wrong? */ ! 185: #endif ! 186: #ifdef ID_CHAR ! 187: disp_opt_init(); ! 188: #endif ! 189: if (CanScroll = ((AL && DL) || CS)) ! 190: IDline_setup(termname); ! 191: } ! 192:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.