예제 #1
0
파일: n6.c 프로젝트: n-t-roff/DWB3.3
int
n_width(Tchar j)
{
	int i, k;

	if (iszbit(j))
		return 0;
	if (ismot(j)) {
		if (isvmot(j))
			return(0);
		k = absmot(j);
		if (isnmot(j))
			k = -k;
		return(k);
	}
	i = cbits(j);
	if (i < ' ') {
		if (i == '\b')
			return(-widthp);
		if (i == PRESC)
			i = eschar;
		else if (i == HX)
			return(0);
	}
	if (i == ohc)
		return(0);
	i = trtab[i];
	if (i < ' ')
		return(0);
	k = t.width[i] * t.Char;
	widthp = k;
	return(k);
}
예제 #2
0
파일: n6.c 프로젝트: n-t-roff/DWB3.3
void n_setwd(void)
{
	int base, wid;
	Tchar i;
	int	delim, emsz, k;
	int	savhp, savapts, savapts1, savfont, savfont1, savpts, savpts1;

	base = numtabp[ST].val = wid = numtabp[CT].val = 0;
	if (ismot(i = getch()))
		return;
	delim = cbits(i);
	savhp = numtabp[HP].val;
	numtabp[HP].val = 0;
	savapts = apts;
	savapts1 = apts1;
	savfont = font;
	savfont1 = font1;
	savpts = pts;
	savpts1 = pts1;
	setwdf++;
	while (cbits(i = getch()) != delim && !nlflg) {
		k = width(i);
		wid += k;
		numtabp[HP].val += k;
		if (!ismot(i)) {
			emsz = (INCH * pts + 36) / 72;
		} else if (isvmot(i)) {
			k = absmot(i);
			if (isnmot(i))
				k = -k;
			base -= k;
			emsz = 0;
		} else 
			continue;
		if (base < numtabp[SB].val)
			numtabp[SB].val = base;
		if ((k = base + emsz) > numtabp[ST].val)
			numtabp[ST].val = k;
	}
	setn1(wid, 0, (Tchar) 0);
	numtabp[HP].val = savhp;
	apts = savapts;
	apts1 = savapts1;
	font = savfont;
	font1 = savfont1;
	pts = savpts;
	pts1 = savpts1;
	mchbits();
	setwdf = 0;
}
예제 #3
0
파일: n10.c 프로젝트: 00001/plan9port
void ptout1(void)
{
	int k;
	char *codep;
	int w, j, phyw;
	Tchar *q, i;
	static int oxfont = FT;	/* start off in roman */

	for (q = oline; q < olinep; q++) {
		i = *q;
		if (ismot(i)) {
			j = absmot(i);
			if (isnmot(i))
				j = -j;
			if (isvmot(i))
				lead += j;
			else 
				esc += j;
			continue;
		}
		if ((k = cbits(i)) <= ' ') {
			switch (k) {
			case ' ': /*space*/
				esc += t.Char;
				break;
			case '\033':
			case '\007':
			case '\016':
			case '\017':
				oput(k);
				break;
			}
			continue;
		}
		phyw = w = t.Char * t.tfont.wp[k].wid;
		if (iszbit(i))
			w = 0;
		if (esc || lead)
			move();
		esct += w;
		xfont = fbits(i);
		if (xfont != oxfont) {
			switch (oxfont) {
			case ULFONT:	oputs(t.itoff); break;
			case BDFONT:	oputs(t.bdoff); break;
			case BIFONT:	oputs(t.itoff); oputs(t.bdoff); break;
			}
			switch (xfont) {
			case ULFONT:
				if (*t.iton & 0377) oputs(t.iton); break;
			case BDFONT:
				if (*t.bdon & 0377) oputs(t.bdon); break;
			case BIFONT:
				if (*t.bdon & 0377) oputs(t.bdon);
				if (*t.iton & 0377) oputs(t.iton);
				break;
			}
			oxfont = xfont;
		}
		if ((xfont == ulfont || xfont == BIFONT) && !(*t.iton & 0377)) {
			for (j = w / t.Char; j > 0; j--)
				oput('_');
			for (j = w / t.Char; j > 0; j--)
				oput('\b');
		}
		if (!(*t.bdon & 0377) && ((j = bdtab[xfont]) || xfont == BDFONT || xfont == BIFONT))
			j++;
		else
			j = 1;	/* number of overstrikes for bold */
		if (k < ALPHABET) {	/* ordinary ascii */
			oput(k);
			while (--j > 0) {
				oput('\b');
				oput(k);
			}
		} else if (k >= t.tfont.nchars) {	/* BUG -- not really understood */
/* fprintf(stderr, "big char %d, name %s\n", k, chname(k)); /* */
			oputs(chname(k)+1);	/* BUG: should separate Troffchar and MBchar... */
		} else if (t.tfont.wp[k].str == 0) {
/* fprintf(stderr, "nostr char %d, name %s\n", k, chname(k)); /* */
			oputs(chname(k)+1);	/* BUG: should separate Troffchar and MBchar... */
		} else if (t.tfont.wp[k].str[0] == MBchar) {	/* parse() puts this on */
/* fprintf(stderr, "MBstr char %d, name %s\n", k, chname(k)); /* */
			oputs(t.tfont.wp[k].str+1);
		} else {
			int oj = j;
/* fprintf(stderr, "str char %d, name %s\n", k, chname(k)); /* */
			codep = t.tfont.wp[k].str+1;	/* Troffchar by default */
			while (*codep != 0) {
				if (*codep & 0200) {
					codep = plot(codep);
					oput(' ');
				} else {
					if (*codep == '%')	/* escape */
						codep++;
					oput(*codep);
					if (*codep == '\033')
						oput(*++codep);
					else if (*codep != '\b')
						for (j = oj; --j > 0; ) {
							oput('\b');
							oput(*codep);
						}
					codep++;
				}
			}
		}
		if (!w)
			for (j = phyw / t.Char; j > 0; j--)
				oput('\b');
	}
}
예제 #4
0
int
pchar(register tchar i)
{
	register int j;
	static int hx = 0;	/* records if have seen HX */
	static int xon = 0;	/* records if have seen XON */
	static int drawfcn = 0;	/* records if have seen DRAWFCN */

	if (hx) {
		hx = 0;
		j = absmot(i);
		if (isnmot(i)) {
			if (j > dip->blss)
				dip->blss = j;
		} else {
			if (j > dip->alss)
				dip->alss = j;
			ralss = dip->alss;
		}
		return 1;
	}
	if (ismot(i)) {
		pchar1(i); 
		return 1;
	}
	switch (j = cbits(i)) {
	case 0:
	case IMP:
	case RIGHT:
	case LEFT:
		if (xflag) {
			i = j = FILLER;	/* avoid kerning in output routine */
			goto dfl;
		}
		return 1;
	case HX:
		hx = 1;
		if (xflag) {
			i = j = FILLER;	/* avoid kerning in output routine */
			goto dfl;
		}
		return 1;
	case XON:
		xon = 1;
		goto dfl;
	case XOFF:
		xon = 0;
		goto dfl;
	case DRAWFCN:
		drawfcn = !drawfcn;
		goto dfl;
	case PRESC:
		if (dip == &d[0])
			j = eschar;	/* fall through */
	default:
	dfl:
#ifndef NROFF
		if (html) {
			if (!xflag || !isdi(i)) {
				setcbits(i, j >= NCHARS ? j :
				    tflg ? trnttab[j] : trtab[j]);
				if (xon == 0 && drawfcn == 0 && i < NCHARS)
					setcbits(i, ftrans(fbits(i),
					    cbits(i)));
			}
		} else
#endif
		if (!xflag || !isdi(i)) {
			setcbits(i, tflg ? trnttab[j] : trtab[j]);
			if (xon == 0 && drawfcn == 0)
				setcbits(i, ftrans(fbits(i), cbits(i)));
		}
	}
#ifdef	NROFF
	if (xon && xflag)
		return 1;
#endif	/* NROFF */
	pchar1(i);
	return 1;
}