1: #include "sdef.h"
   2: #include "d.h"
   3: #include "v.h"
   4: #include "tw.h"
   5: /*
   6: sroff6.c
   7: 
   8: width functions, sizes and fonts
   9: */
  10: 
  11: extern int eschar;
  12: extern int widthp;
  13: extern int ohc;
  14: extern int xfont;
  15: extern int setwdf;
  16: extern char trtab[];
  17: extern int chbits;
  18: extern int nonumb;
  19: extern int noscale;
  20: extern int font;
  21: extern int font1;
  22: extern int ulfont;
  23: extern int space;
  24: extern int sps;
  25: extern int nlflg;
  26: extern int nform;
  27: extern int dfact;
  28: extern int dfactd;
  29: extern int lss;
  30: extern int lss1;
  31: extern int vflag;
  32: extern int ch0;
  33: extern int level;
  34: extern int ch;
  35: extern int xxx;
  36: extern int bdtab[];
  37: extern int sbold;
  38: extern int smnt;
  39: extern int ul;
  40: extern int cu;
  41: extern int fontab[PFONT][0200-040];
  42: extern int fontabS[];
  43: extern char *codetab[];
  44: extern int Em;
  45: 
  46: width(c)
  47: int c;
  48: {
  49:     register i,j,k;
  50: 
  51:     j = c;
  52:     k = 0;
  53:     if(j & MOT){
  54:         if(j & VMOT)goto rtn;
  55:         k = j & ~MOTV;
  56:         if(j & NMOT)k = -k;
  57:         goto rtn;
  58:     }
  59:     if((i = (j & CMASK)) == 010){
  60:         k = -widthp;
  61:         goto rtn;
  62:     }
  63:     if(i == PRESC)i = eschar;
  64:     if((i == ohc) ||
  65:        (i >= MAXCHAR))goto rtn;
  66:     if(j & ZBIT)goto rtn;
  67:     i = trtab[i] & BMASK;
  68:     if(i < 040)goto rtn;
  69:         /* stan, if EBIT is on pass character without counting it */
  70:     if (!(j & EBIT))
  71:         k = getcw((j & ~CMASK) | i);
  72:     widthp = k;
  73: rtn:
  74:     return(k);
  75: }
  76: getcw(i)
  77: int i;
  78: {
  79:     register ft, k;
  80:     register struct fonts *fp;
  81: 
  82:     fp = &fonts[getfont(i)];
  83:     ft = fp->phys;
  84:     k = i & CMASK;
  85: 
  86:     if (k>0177)
  87:         k = fontabS[k-0200] & WDMASK;
  88:     else if (ft & PROPOR)
  89:         k = fontab[ft&~PROPOR][k-32] & WDMASK;
  90:     else k = fp->Char;
  91:     return(k);
  92: }
  93: setch(){
  94:     register i,*j,k;
  95:     extern int chtab[];
  96: 
  97:     if((i = getrq()) == 0)return(0);
  98:     for(j=chtab;*j != i;j++)if(*(j++) == 0)return(0);
  99:     k = *(++j) | chbits;
 100:     return(k);
 101: }
 102: findft(i)
 103: int i;
 104: {
 105:     register k;
 106: 
 107: #if NFONTS > 8
 108:     k = (i & BMASK) - '0';
 109:     if (i & ~BMASK)
 110:         k += (((i>>8) & BMASK) - '0') * 10;
 111: #else
 112:     k = i - '0';
 113: #endif
 114:     if((k >= 1) && (k <= NFONTS))return(--k);
 115:     for(k=0; k < NFONTS; k++)
 116:         if (fonts[k].lab == i) return(k);
 117:     return(-1);
 118: }
 119: mchbits(){
 120:     if (font == ulfont)
 121:         chbits = 0|ULMODE;  /* use font 0 */
 122:     else chbits = (font << FONTSHFT);
 123:     space = ' ' | chbits;
 124:     if (ul) chbits |= ULMODE;
 125:     if (cu) space |= ULMODE;
 126:     sps = width(space);
 127:     Em = fonts[font].Em;
 128: }
 129: setps(){
 130:     register i,j;
 131: 
 132:     if((((i=getch() & CMASK) == '+')  || (i == '-')) &&
 133:       (((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9))){
 134:         ch = 0;
 135:         return;
 136:     }
 137:     if((i -= '0') == 0){
 138:         return;
 139:     }
 140:     if((i > 0) && (i <= 9)){
 141:         if((i <= 3) &&
 142:           ((j=(ch = getch() & CMASK) - '0') >= 0) && (j <= 9)){
 143:             ch = 0;
 144:         }
 145:     }
 146: }
 147: caseft(){
 148:     skip();
 149:     setfont(1);
 150: }
 151: setfont(a)
 152: int a;
 153: {
 154:     register i,j;
 155: 
 156:     if(a)i = getrq();
 157:         else i = getsn();
 158:     if(!i || (i == 'P')){
 159:         j = font1;
 160:         goto s0;
 161:     }
 162:     if((j = findft(i))  == -1)return;
 163: s0:
 164:     font1 = font;
 165:     font = j;
 166:     mchbits();
 167: }
 168: setwd(){
 169:     register i, base, wid;
 170:     int delim, em, k;
 171:     int savlevel, savhp, savfont, savfont1;
 172: 
 173:     base = v.st = v.sb = wid = v.ct = 0;
 174:     if((delim = getch() & CMASK) & MOT)return;
 175:     savhp = v.hp;
 176:     savlevel = level;
 177:     v.hp = level = 0;
 178:     savfont = font;
 179:     savfont1 = font1;
 180:     setwdf++;
 181:     while((((i = getch()) & CMASK) != delim) && !nlflg){
 182:         wid += width(i);
 183:         if(!(i & MOT)){
 184:             em = 2*t.Halfline;
 185:         }else if(i & VMOT){
 186:             k = i & ~MOTV;
 187:             if(i & NMOT)k = -k;
 188:             base -= k;
 189:             em = 0;
 190:         }else continue;
 191:         if(base < v.sb)v.sb = base;
 192:         if((k=base + em) > v.st)v.st = k;
 193:     }
 194:     nform = 0;
 195:     setn1(wid);
 196:     v.hp = savhp;
 197:     level = savlevel;
 198:     font = savfont;
 199:     font1 = savfont1;
 200:     mchbits();
 201:     setwdf = 0;
 202: }
 203: vmot(){
 204:     dfact = lss;
 205:     vflag++;
 206:     return(mot());
 207: }
 208: hmot(){
 209:     dfact = Em;
 210:     return(mot());
 211: }
 212: mot(){
 213:     register i, j;
 214: 
 215:     getch(); /*eat delim*/
 216:     if(i = atoi())
 217:         i = makem(i);
 218:     getch();
 219:     vflag = 0;
 220:     dfact = 1;
 221:     return(i);
 222: }
 223: sethl(k)
 224: int k;
 225: {
 226:     register i;
 227: 
 228:     i = Em/2;
 229:     if(k == 'u')i = -i;
 230:     else if(k == 'r')i = -Em;
 231:     vflag++;
 232:     i = makem(i);
 233:     vflag = 0;
 234:     return(i);
 235: }
 236: makem(i)
 237: int i;
 238: {
 239:     register j;
 240: 
 241:     if((j = i) < 0)j = -j;
 242:     j = (j & ~MOTV) | MOT;
 243:     if(i < 0)j |= NMOT;
 244:     if(vflag)j |= VMOT;
 245:     return(j);
 246: }
 247: casefp(){
 248:     register i, j;
 249: 
 250:     skip();
 251:     if(((i = (getch() & CMASK) - '0' -1) < 0) || (i >NFONTS))return;
 252:     if(skip() || !(j = getrq()))return;
 253:     fonts[i].lab = j;
 254: }
 255: casevs(){
 256:     register i;
 257: 
 258:     skip();
 259:     vflag++;
 260:     dfact = INCH; /*default scaling is points!*/
 261:     dfactd = 72;
 262:     i = inumb(&lss);
 263:     if(nonumb)i = lss1;
 264:     if(i < VERT)i = VERT;
 265:     lss1 = lss;
 266:     lss = i;
 267: }
 268: xlss(){
 269:     register i, j;
 270: 
 271:     getch();
 272:     dfact = lss;
 273:     i = atoi();
 274:     dfact = 1;
 275:     getch();
 276:     if((j = i) < 0)j = -j;
 277:     ch0 = ((j & 03700)<<3) | HX;
 278:     if(i < 0)ch0 |= 040000;
 279:     return(((j & 077)<<9) | LX);
 280: }
 281: casefz(){}
 282: caseps(){}
 283: caselg(){}
 284: casecs(){}
 285: casebd(){
 286:     register i, j, k;
 287: 
 288:     if(skip() || !(i = getrq()) ||
 289:       ((j = findft(i))  == -1))
 290:         return;
 291:     if (j == smnt) {
 292:         if(skip() || !(i = getrq()) ||
 293:             ((k = findft(i))  == -1)) {
 294:             bdtab[smnt] = 0;
 295:             return;
 296:         }
 297:         sbold = k;
 298:     }
 299:     skip();
 300:     noscale++;
 301:     bdtab[j] = atoi();
 302:     noscale = 0;
 303: }
 304: casess(){}
 305: getlg(i)
 306: int i;
 307: {
 308:     return(i);
 309: }

Defined functions

casebd defined in line 285; used 2 times
casecs defined in line 284; used 2 times
casefp defined in line 247; used 2 times
caseft defined in line 147; used 2 times
casefz defined in line 281; never used
caselg defined in line 283; used 2 times
caseps defined in line 282; used 2 times
casess defined in line 304; used 2 times
casevs defined in line 255; used 2 times
findft defined in line 102; used 4 times
getcw defined in line 76; used 7 times
getlg defined in line 305; used 1 times
hmot defined in line 208; used 1 times
makem defined in line 236; used 19 times
mchbits defined in line 119; used 7 times
mot defined in line 212; used 2 times
setch defined in line 93; used 1 times
setfont defined in line 151; used 2 times
sethl defined in line 223; used 1 times
setps defined in line 129; used 1 times
setwd defined in line 168; used 1 times
vmot defined in line 203; used 1 times
width defined in line 46; used 24 times
xlss defined in line 268; used 1 times
Last modified: 1982-02-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1231
Valid CSS Valid XHTML 1.0 Strict