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: }

Defined functions

TermError defined in line 110; used 4 times
getTERM defined in line 118; used 1 times
gets defined in line 101; used 1 times

Defined variables

AL defined in line 32; used 3 times
BC defined in line 45; used 2 times
CE defined in line 30; used 2 times
CL defined in line 29; used 2 times
CM defined in line 28; used 2 times
CO defined in line 63; used 1 times
CS defined in line 25; used 6 times
DC defined in line 41; used 2 times
DL defined in line 33; used 3 times
EI defined in line 43; used 2 times
HO defined in line 31; used 2 times
HOlen defined in line 72; never used
IC defined in line 40; used 2 times
ILI defined in line 62; used 1 times
IM defined in line 42; used 5 times
IP defined in line 58; used 2 times
KE defined in line 37; used 2 times
KS defined in line 36; used 2 times
LI defined in line 61; used 1 times
LL defined in line 44; used 2 times
LLlen defined in line 73; never used
MI defined in line 66; used 1 times
M_AL defined in line 48; used 2 times
M_DC defined in line 47; used 2 times
M_DL defined in line 49; used 2 times
M_IC defined in line 46; used 2 times
RE defined in line 55; used 3 times
RS defined in line 54; used 3 times
SE defined in line 27; used 4 times
SF defined in line 50; used 5 times
SG defined in line 67; used 2 times
SO defined in line 26; used 4 times
SP defined in line 52; used 2 times
SR defined in line 51; used 4 times
TABS defined in line 70; never used
TE defined in line 39; used 2 times
TI defined in line 38; used 2 times
UL defined in line 65; used 1 times
UP defined in line 24; used 2 times
UPlen defined in line 71; never used
VB defined in line 57; used 2 times
VE defined in line 35; used 2 times
VS defined in line 34; used 2 times
XS defined in line 68; used 3 times
lPC defined in line 59; used 4 times
meas defined in line 92; used 2 times
ospeed defined in line 75; never used
ts defined in line 91; used 2 times
tspace defined in line 78; used 1 times
Last modified: 1986-03-28
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2076
Valid CSS Valid XHTML 1.0 Strict