15 if (!ismot(i = getch()))
25 int j, w, cnt, delim, rem, temp;
28 if (ismot(c = getch()))
33 length = quant(atoi0(), HOR);
40 if ((j = cbits(c = getch())) == delim || j == '\n') {
43 } else if (cbits(c) == FILLER)
47 ERROR "zero-width underline character ignored" WARN;
56 if (!(cnt = length / w)) {
57 *i++ = makem(-(temp = ((w - length) / 2)));
59 *i++ = makem(-(w - length - temp));
62 if (rem = length % w) {
63 if (cbits(c) == RULE || cbits(c) == UNDERLINE || cbits(c) == ROOTEN)
83 while ((i = cbits(getch())) != c && i != '\n')
95 if (ismot(i = getch()))
98 for (k = 0; k < NOV && (j = cbits(i = getch())) != delim && j != '\n'; k++) {
106 for (k = 1; o[k] ; k++) {
120 *pbp++ = makem(w[0] / 2);
121 for (k = 0; o[k]; k++)
125 *pbp++ = makem(-((w[k] + w[k+1]) / 2));
138 if (ismot(i = getch()))
144 dwn = (2 * t.Halfline) | MOT | VMOT;
146 dwn = EM | MOT | VMOT;
147 while ((k = cbits(i = getch())) != delim && k != '\n' && j <= brabuf + NC - 4) {
160 *--j = *brabuf = (cnt * t.Halfline) | MOT | NMOT | VMOT;
162 *--j = *brabuf = (cnt * EM) / 2 | MOT | NMOT | VMOT;
171 Tchar c, rem, ver, neg;
176 if (ismot(c = getch()))
181 i = quant(atoi0(), VERT);
188 if ((cbits(c = getch())) == delim) {
189 c = BOXRULE | chbits; /*default box rule*/
202 if (v < VERT) /* ATT EVK hack: Erik van Konijnenburg, */
203 v = VERT; /* hvlpb!evkonij, ATT NSI Hilversum, Holland */
207 rem = makem(i % v) | neg;
208 ver = makem(v) | neg;
212 if (absmot(rem) != 0) {
216 while (vlp < vlbuf + NC - 3 && cnt--) {
228 #define NPAIR (NC/2-6) /* max pairs in spline, etc. */
230 void setdraw(void) /* generate internal cookies for a drawing function */
232 int i, j, k, dx[NPAIR], dy[NPAIR], delim, type;
233 Tchar c, drawbuf[NC];
234 int drawch = '.'; /* character to draw with */
236 /* input is \D'f dx dy dx dy ... c' (or at least it had better be) */
237 /* this does drawing function f with character c and the */
238 /* specified dx,dy pairs interpreted as appropriate */
239 /* pairs are deltas from last point, except for radii */
241 /* l dx dy: line from here by dx,dy */
242 /* c x: circle of diameter x, left side here */
243 /* e x y: ellipse of diameters x,y, left side here */
244 /* a dx1 dy1 dx2 dy2:
245 ccw arc: ctr at dx1,dy1, then end at dx2,dy2 from there */
246 /* ~ dx1 dy1 dx2 dy2...:
247 spline to dx1,dy1 to dx2,dy2 ... */
249 built-up character of type c, ht x */
250 /* f dx dy ...: f is any other char: like spline */
252 if (ismot(c = getch()))
255 numerr.escarg = type = cbits(getch());
256 if (type == '~') /* head off the .tr ~ problem */
258 for (i = 0; i < NPAIR ; i++) {
262 dx[i] = quant(atoi0(), HOR);
265 else if (dx[i] < -MAXMOT)
274 dy[i] = quant(atoi0(), VERT);
277 else if (dy[i] < -MAXMOT)
280 if (cbits(c = getch()) != ' ') { /* must be the end */
281 if (cbits(c) != delim) {
292 drawbuf[0] = DRAWFCN | chbits | ZBIT;
293 drawbuf[1] = type | chbits | ZBIT;
294 drawbuf[2] = drawch | chbits | ZBIT;
295 for (k = 0, j = 3; k < i; k++) {
296 drawbuf[j++] = MOT | ((dx[k] >= 0) ? dx[k] : (NMOT | -dx[k]));
297 drawbuf[j++] = MOT | VMOT | ((dy[k] >= 0) ? dy[k] : (NMOT | -dy[k]));
299 if (type == DRAWELLIPSE) {
300 drawbuf[5] = drawbuf[4] | NMOT; /* so the net vertical is zero */
302 } else if (type == DRAWBUILD) {
303 drawbuf[4] = drawbuf[3] | NMOT; /* net horizontal motion is zero */
304 drawbuf[2] &= ~ZBIT; /* width taken from drawing char */
307 drawbuf[j++] = DRAWFCN | chbits | ZBIT; /* marks end for ptout */
319 gchtab[fc] &= ~FCBIT;
322 if (skip() || ismot(j = getch()) || (i = cbits(j)) == '\n')
326 if (skip() || ismot(ch) || (ch = cbits(ch)) == fc)
332 Tchar setfield(int x)
336 int length, ws, npad, temp, type;
337 Tchar **pp, *padptr[NPP];
339 int savfc, savtc, savlc;
342 static Tchar wbuf[] = { WORDSP, 0};
346 rchar = tabc | chbits;
348 rchar = dotc | chbits;
349 temp = npad = ws = 0;
353 tabch = ldrch = fc = IMP;
354 savepos = numtabp[HP].val;
355 gchtab[tabch] &= ~TABBIT;
356 gchtab[ldrch] &= ~LDRBIT;
357 gchtab[fc] &= ~FCBIT;
358 gchtab[IMP] |= TABBIT|LDRBIT|FCBIT;
360 if ((tabtab[j] & TABMASK) == 0) {
362 ERROR "zero field width." WARN;
366 if ((length = ((tabtab[j] & TABMASK) - numtabp[HP].val)) > 0 )
369 type = tabtab[j] & ~TABMASK;
374 j = cbits(ii = getch());
377 numtabp[HP].val += jj;
381 if (pp > padptr + NPP - 1)
384 } else if (j == savfc)
386 else if (j == '\n') {
388 if (nlflg && ip == 0) {
397 if (fp > fbuf + FBUFSZ - 3)
409 temp = i = (j = length - ws) / npad;
411 if ((j -= i * npad) < 0)
416 for (; npad > 0; npad--) {
425 } else if (type == 0) {
426 /*plain tab or leader*/
427 if ((j = width(rchar)) > 0) {
428 int nchar = length / j;
429 while (nchar-->0 && pbp < &pbbuf[NC-3]) {
430 numtabp[HP].val += j;
445 while ((j = cbits(ii = getch())) != savtc && j != '\n' && j != savlc) {
448 numtabp[HP].val += jj;
451 if (fp > fbuf + FBUFSZ - 3)
459 length -= ws / 2; /*CTAB*/
461 if ((j = width(rchar)) != 0 && length > 0) {
462 int nchar = length / j;
463 while (nchar-- > 0 && pbp < &pbbuf[NC-3])
469 length = (length / HOR) * HOR;
478 gchtab[fc] &= ~FCBIT;
479 gchtab[tabch] &= ~TABBIT;
480 gchtab[ldrch] &= ~LDRBIT;
485 gchtab[tabch] = TABBIT;
486 gchtab[ldrch] |= LDRBIT;
487 numtabp[HP].val = savepos;