|
|
1.1 ! root 1: /*************************************************************************** ! 2: * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne. JOVE * ! 3: * is provided to you without charge, and with no warranty. You may give * ! 4: * away copies of JOVE, including sources, provided that this notice is * ! 5: * included in all the files. * ! 6: ***************************************************************************/ ! 7: ! 8: #include "jove.h" ! 9: #include <ctype.h> ! 10: #include <errno.h> ! 11: ! 12: #ifndef MAC /* most of the file... */ ! 13: ! 14: #ifndef MSDOS ! 15: # ifdef SYSV ! 16: # include <termio.h> ! 17: # else ! 18: # include <sgtty.h> ! 19: # endif /* SYSV */ ! 20: #endif /* MSDOS */ ! 21: ! 22: #ifdef IPROCS ! 23: # include <signal.h> ! 24: #endif ! 25: ! 26: #define _TERM ! 27: #include "termcap.h" ! 28: ! 29: /* Termcap definitions */ ! 30: ! 31: #ifndef IBMPC ! 32: char *CS, ! 33: *SO, ! 34: *SE, ! 35: *CM, ! 36: *CL, ! 37: *CE, ! 38: *HO, ! 39: *AL, ! 40: *DL, ! 41: *VS, ! 42: *VE, ! 43: *KS, ! 44: *KE, ! 45: *TI, ! 46: *TE, ! 47: *IC, ! 48: *DC, ! 49: *IM, ! 50: *EI, ! 51: *LL, ! 52: *M_IC, /* Insert char with arg */ ! 53: *M_DC, /* Delete char with arg */ ! 54: *M_AL, /* Insert line with arg */ ! 55: *M_DL, /* Delete line with arg */ ! 56: *SF, /* Scroll forward */ ! 57: *SR, ! 58: *SP, /* Send Cursor Position */ ! 59: *VB, ! 60: *BL, ! 61: *IP, /* insert pad after character inserted */ ! 62: *lPC, ! 63: *NL; ! 64: #endif ! 65: ! 66: int LI, ! 67: ILI, /* Internal lines, i.e., 23 of LI is 24. */ ! 68: CO, ! 69: ! 70: UL, ! 71: MI, ! 72: SG, /* number of magic cookies left by SO and SE */ ! 73: XS, /* whether standout is braindamaged */ ! 74: ! 75: TABS, ! 76: UPlen, ! 77: HOlen, ! 78: LLlen; ! 79: ! 80: extern char PC, ! 81: *BC, ! 82: *UP; ! 83: ! 84: #ifdef notdef ! 85: /* ! 86: * Are you sure about this one Jon? On the SYSV system I tried this ! 87: * on I got a multiple definition of PC because it was already ! 88: * defined in -ltermcap. Similarly for BC and UP ... ! 89: */ ! 90: # ifdef SYSVR2 /* release 2, at least */ ! 91: char PC; ! 92: # else ! 93: extern char PC; ! 94: # endif /* SYSVR2 */ ! 95: #endif ! 96: ! 97: #ifndef IBMPC ! 98: static char tspace[256]; ! 99: ! 100: /* The ordering of ts and meas must agree !! */ ! 101: static char *ts="vsvealdlspcssosecmclcehoupbcicimdceillsfsrvbksketiteALDLICDCpcipblnl"; ! 102: static char **meas[] = { ! 103: &VS, &VE, &AL, &DL, &SP, &CS, &SO, &SE, ! 104: &CM, &CL, &CE, &HO, &UP, &BC, &IC, &IM, ! 105: &DC, &EI, &LL, &SF, &SR, &VB, &KS, &KE, ! 106: &TI, &TE, &M_AL, &M_DL, &M_IC, &M_DC, ! 107: &lPC, &IP, &BL, &NL, 0 ! 108: }; ! 109: ! 110: static void ! 111: gets(buf) ! 112: char *buf; ! 113: { ! 114: buf[read(0, buf, 12) - 1] = 0; ! 115: } ! 116: ! 117: /* VARARGS1 */ ! 118: ! 119: static void ! 120: TermError(fmt, a) ! 121: char *fmt; ! 122: { ! 123: printf(fmt, a); ! 124: flusho(); ! 125: _exit(1); ! 126: } ! 127: ! 128: void ! 129: getTERM() ! 130: { ! 131: char *getenv(), *tgetstr() ; ! 132: char termbuf[13], ! 133: *termname = NULL, ! 134: *termp = tspace, ! 135: tbuff[2048]; /* Good grief! */ ! 136: int i; ! 137: ! 138: termname = getenv("TERM"); ! 139: if ((termname == NULL) || (*termname == '\0') || ! 140: (strcmp(termname, "dumb") == 0) || ! 141: (strcmp(termname, "unknown") == 0) || ! 142: (strcmp(termname, "network") == 0)) { ! 143: putstr("Enter terminal type (e.g, vt100): "); ! 144: flusho(); ! 145: gets(termbuf); ! 146: if (termbuf[0] == 0) ! 147: TermError(NullStr); ! 148: ! 149: termname = termbuf; ! 150: } ! 151: ! 152: if (tgetent(tbuff, termname) < 1) ! 153: TermError("[\"%s\" unknown terminal type?]", termname); ! 154: ! 155: if ((CO = tgetnum("co")) == -1) ! 156: wimperr: TermError("You can't run JOVE on a %s terminal.\n", termname); ! 157: ! 158: else if (CO > MAXCOLS) ! 159: CO = MAXCOLS; ! 160: ! 161: if ((LI = tgetnum("li")) == -1) ! 162: goto wimperr; ! 163: ! 164: if ((SG = tgetnum("sg")) == -1) ! 165: SG = 0; /* Used for mode line only */ ! 166: ! 167: if ((XS = tgetflag("xs")) == -1) ! 168: XS = 0; /* Used for mode line only */ ! 169: ! 170: for (i = 0; meas[i]; i++) { ! 171: *(meas[i]) = (char *) tgetstr(ts, &termp); ! 172: ts += 2; ! 173: } ! 174: if (lPC) ! 175: PC = *lPC; ! 176: if (XS) ! 177: SO = SE = 0; ! 178: ! 179: if (CS && !SR) ! 180: CS = SR = SF = 0; ! 181: ! 182: if (CS && !SF) ! 183: SF = "\n"; ! 184: ! 185: if (IM && (*IM == 0)) ! 186: IM = 0; ! 187: else ! 188: MI = tgetflag("mi"); ! 189: ! 190: UL = tgetflag("ul"); ! 191: ! 192: if (NL == 0) ! 193: NL = "\n"; ! 194: else { /* strip stupid padding information */ ! 195: while (isdigit(*NL)) ! 196: NL += 1; ! 197: if (*NL == '*') ! 198: NL += 1; ! 199: } ! 200: ! 201: if (BL == 0) ! 202: BL = "\007"; ! 203: ! 204: #ifdef ID_CHAR ! 205: disp_opt_init(); ! 206: #endif ! 207: if (CanScroll = ((AL && DL) || CS)) ! 208: IDline_setup(termname); ! 209: } ! 210: ! 211: #else ! 212: ! 213: void ! 214: InitCM() ! 215: { ! 216: } ! 217: ! 218: int EGA; ! 219: ! 220: void ! 221: getTERM() ! 222: { ! 223: char *getenv(), *tgetstr() ; ! 224: char *termname; ! 225: void init_43(), init_term(); ! 226: unsigned char lpp(), chpl(); ! 227: ! 228: if (getenv("EGA") || (!stricmp(getenv("TERM"), "EGA"))) { ! 229: termname = "ega"; ! 230: init_43(); ! 231: EGA = 1; ! 232: } ! 233: else { ! 234: termname = "ibmpc"; ! 235: init_term(); ! 236: EGA = 0; ! 237: } ! 238: ! 239: CO = chpl(); ! 240: LI = lpp(); ! 241: ! 242: SG = 0; /* Used for mode line only */ ! 243: XS = 0; /* Used for mode line only */ ! 244: ! 245: CanScroll = 1; ! 246: } ! 247: ! 248: #endif /* IBMPC */ ! 249: ! 250: #else /* MAC */ ! 251: int LI, ! 252: ILI, /* Internal lines, i.e., 23 of LI is 24. */ ! 253: CO, ! 254: TABS, ! 255: SG; ! 256: ! 257: void getTERM() ! 258: { ! 259: SG = 0; ! 260: CanScroll = 1; ! 261: } ! 262: ! 263: #endif /* MAC */ ! 264: ! 265:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.