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 */

Defined functions

InitCM defined in line 213; never used
TermError defined in line 119; used 3 times
getTERM defined in line 257; used 3 times
gets defined in line 110; used 1 times

Defined variables

AL defined in line 39; used 2 times
BL defined in line 60; used 3 times
CE defined in line 37; used 1 times
CL defined in line 36; used 1 times
CM defined in line 35; used 1 times
CO defined in line 253; used 4 times
CS defined in line 32; used 5 times
DC defined in line 48; used 1 times
DL defined in line 40; used 2 times
EGA defined in line 218; used 4 times
EI defined in line 50; used 1 times
HO defined in line 38; used 1 times
HOlen defined in line 77; never used
IC defined in line 47; used 1 times
ILI defined in line 252; used 1 times
IM defined in line 49; used 4 times
IP defined in line 61; used 1 times
KE defined in line 44; used 1 times
KS defined in line 43; used 1 times
LI defined in line 251; used 2 times
LL defined in line 51; used 1 times
LLlen defined in line 78; never used
MI defined in line 71; used 1 times
M_AL defined in line 54; used 1 times
M_DC defined in line 53; used 1 times
M_DL defined in line 55; used 1 times
M_IC defined in line 52; used 1 times
NL defined in line 63; used 7 times
PC declared in line 8093; defined in line 91; used 1 times
SE defined in line 34; used 2 times
SF defined in line 56; used 4 times
SG defined in line 255; used 4 times
SO defined in line 33; used 2 times
SP defined in line 58; used 1 times
SR defined in line 57; used 3 times
TABS defined in line 254; never used
TE defined in line 46; used 1 times
TI defined in line 45; used 1 times
UL defined in line 70; used 1 times
UPlen defined in line 76; never used
VB defined in line 59; used 1 times
VE defined in line 42; used 1 times
VS defined in line 41; used 1 times
XS defined in line 73; used 4 times
lPC defined in line 62; used 3 times
meas defined in line 102; used 2 times
ts defined in line 101; used 2 times
tspace defined in line 98; used 1 times

Defined macros

_TERM defined in line 26; never used
Last modified: 1988-03-22
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 607
Valid CSS Valid XHTML 1.0 Strict