|
|
1.1 ! root 1: #include "tdef.hd" ! 2: #include "strs.hd" ! 3: #ifdef NROFF ! 4: #include "tw.hd" ! 5: #endif ! 6: ! 7: /* ! 8: troff6.c ! 9: ! 10: width functions, sizes and fonts ! 11: */ ! 12: ! 13: #ifndef INCORE ! 14: extern struct envblock eblock; ! 15: #else ! 16: extern struct envblock eblock[NEV]; ! 17: extern int ev; ! 18: #endif ! 19: extern struct ttable t; ! 20: extern struct datablock dblock; ! 21: extern struct tmpfaddr ip; ! 22: ! 23: extern int Hipb; ! 24: extern int tch[]; ! 25: extern int *cstk[], cstkl; ! 26: extern int ch_CMASK; ! 27: extern long atoi0(); ! 28: int sbold = 0; ! 29: int bdtab[4] = {0, 0, 3, 0}; ! 30: extern int eschar; ! 31: extern int widthp; ! 32: extern int xfont; ! 33: extern int smnt; ! 34: extern int setwdf; ! 35: extern int nonumb; ! 36: extern int noscale; ! 37: extern int nlflg; ! 38: extern int nform; ! 39: extern int dfact; ! 40: extern int dfactd; ! 41: extern int vflag; ! 42: extern int level; ! 43: extern int ch; ! 44: extern int res; ! 45: int fontlab[] = {'R','I','B','S',0}; ! 46: width(c) ! 47: int c; ! 48: { ! 49: register i; ! 50: ! 51: if(c & MOT){ ! 52: if (c & VMOT) return (0); ! 53: i = c & ~MOTV; ! 54: return ((c & NMOT) ? -i : i); ! 55: } ! 56: if((i = (c & CMASK)) == 010) return (-widthp); ! 57: if(i == PRESC)i = eschar; ! 58: if((i == ohc) || (i >= 0370) || (c & ZBIT)) return (0); ! 59: i = trtab[i] & BMASK; ! 60: if(i < 040) return (0); ! 61: if (t.codetab[i-32] == 0) return (0); ! 62: return (widthp = (*(t.codetab[i-32]) & 0177) * t.Char); ! 63: } ! 64: setch(){ ! 65: register i,*j; ! 66: extern int chtab[]; ! 67: ! 68: if((i = getrq()) == 0)return(0); ! 69: for(j=chtab;*j != i;j++)if(*(j++) == 0)return(0); ! 70: return (*(++j) | chbits); ! 71: } ! 72: find(i,j) ! 73: int i,j[]; ! 74: { ! 75: register k; ! 76: ! 77: if(((k = i-'0') >= 1) && (k <= 4) && (k != smnt))return(--k); ! 78: for(k=0; j[k] != i; k++)if(j[k] == 0)return(-1); ! 79: return(k); ! 80: } ! 81: mchbits(){ ! 82: chbits = (((pts)<<2) | font) << (BYTE + 1); ! 83: sps = width(' ' | chbits); ! 84: } ! 85: setps(){ ! 86: register i,j; ! 87: ! 88: if((((i=getch() & CMASK) == '+') || (i == '-')) && ! 89: (((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9))){ ! 90: ch = 0; ! 91: return; ! 92: } ! 93: if((i -= '0') == 0){ ! 94: return; ! 95: } ! 96: if((i > 0) && (i <= 9)){ ! 97: if((i <= 3) && ! 98: ((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9)){ ! 99: i = 10*i +j; ! 100: ch = 0; ! 101: } ! 102: } ! 103: } ! 104: caseft(){ ! 105: skip(); ! 106: setfont(1); ! 107: } ! 108: setfont(a) ! 109: int a; ! 110: { ! 111: register i,j; ! 112: ! 113: if(a)i = getrq(); ! 114: else i = getsn(); ! 115: if(!i || (i == 'P')) ! 116: j = font1; ! 117: else if ((i == 'S') || ((j = find(i,fontlab)) == -1)) ! 118: return; ! 119: font1 = font; ! 120: font = j; ! 121: if (font == 1) Hipb = -2; /* mark italic (not cu) to gettch */ ! 122: else if (Hipb == -2) /* clear Hipb */ ! 123: Hipb = -1; ! 124: mchbits(); ! 125: } ! 126: setwd(){ ! 127: register i, base, wid; ! 128: int delim, em, k; ! 129: int savlevel, savhp, savfont, savfont1; ! 130: ! 131: base = v_st = v_sb = wid = v_ct = 0; ! 132: if (getch() && ((delim = ch_CMASK) & MOT)) return; ! 133: savhp = v_hp; ! 134: savlevel = level; ! 135: v_hp = level = 0; ! 136: savfont = font; ! 137: savfont1 = font1; ! 138: setwdf++; ! 139: while ((i = getch()) && (ch_CMASK != delim) && !nlflg) { ! 140: wid += width(i); ! 141: if(!(i & MOT)){ ! 142: em = 2*t.Halfline; ! 143: }else if(i & VMOT){ ! 144: k = i & ~MOTV; ! 145: if(i & NMOT)k = -k; ! 146: base -= k; ! 147: em = 0; ! 148: }else continue; ! 149: if(base < v_sb)v_sb = base; ! 150: if((k=base + em) > v_st)v_st = k; ! 151: } ! 152: nform = 0; ! 153: setn1(wid); ! 154: v_hp = savhp; ! 155: level = savlevel; ! 156: font = savfont; ! 157: font1 = savfont1; ! 158: mchbits(); ! 159: setwdf = 0; ! 160: } ! 161: mot(){ ! 162: register i, j; ! 163: ! 164: j = HOR; ! 165: getch(); /*eat delim*/ ! 166: if(i = atoi()){ ! 167: if(vflag)j = VERT; ! 168: i = makem(quant(i,j)); ! 169: } ! 170: getch(); ! 171: vflag = 0; ! 172: dfact = 1; ! 173: return(i); ! 174: } ! 175: sethl(k) ! 176: int k; ! 177: { ! 178: register i; ! 179: ! 180: i = t.Halfline; ! 181: if(k == 'u')i = -i; ! 182: else if(k == 'r')i = -2*i; ! 183: vflag++; ! 184: i = makem(i); ! 185: vflag = 0; ! 186: return(i); ! 187: } ! 188: makem(i) ! 189: int i; ! 190: { ! 191: register j; ! 192: ! 193: if((j = i) < 0)j = -j; ! 194: j = (j & ~MOTV) | MOT; ! 195: if(i < 0)j |= NMOT; ! 196: if(vflag)j |= VMOT; ! 197: return(j); ! 198: } ! 199: casefp(){ ! 200: register i, j; ! 201: ! 202: skip(); ! 203: if(((i = (getch() & CMASK) - '0' -1) < 0) || (i >3))return; ! 204: if(skip() || !(j = getrq()))return; ! 205: fontlab[i] = j; ! 206: } ! 207: casevs(){ ! 208: register i; ! 209: ! 210: skip(); ! 211: vflag++; ! 212: dfact = INCH; /*default scaling is points!*/ ! 213: dfactd = 72; ! 214: res = VERT; ! 215: i = inumb(&lss); ! 216: if(nonumb)i = lss1; ! 217: if(i < VERT)i = VERT; ! 218: lss1 = lss; ! 219: lss = i; ! 220: } ! 221: xlss(){ ! 222: register i, j; ! 223: ! 224: getch(); ! 225: dfact = lss; ! 226: i = quant(atoi(),VERT); ! 227: dfact = 1; ! 228: getch(); ! 229: if((j = i) < 0)j = -j; ! 230: setch0(((j & 03700)<<3) | HX); ! 231: if(i < 0) setch0(tch[0] | 040000); ! 232: return(((j & 077)<<9) | LX); ! 233: } ! 234: casebd() ! 235: /* this code for bold overstrike courtesy of cb btl */ ! 236: { ! 237: register i, j, k; ! 238: ! 239: k = 0; ! 240: bd0: ! 241: if (skip() || !(i = getrq()) || ! 242: ((j = find(i,fontlab)) == -1)) { ! 243: if (k) goto bd1; ! 244: else return; } ! 245: if (j == (smnt - 1)) { ! 246: k = smnt; ! 247: goto bd0; } ! 248: if (k) { ! 249: sbold = j + 1; ! 250: j = k - 1; } ! 251: bd1: ! 252: skip(); ! 253: noscale++; ! 254: k = atoi(); ! 255: bdtab[j] = ((k < 0) || (k > 50)) ? 0 : k; ! 256: noscale = 0; ! 257: } ! 258: caseps(){} ! 259: caselg(){} ! 260: casecs(){} ! 261: casess(){}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.