Exemplo n.º 1
0
int
interv(int i, int c)
{
int ku, kl;
if (c>=ncol || c == 0)
	{
	if (dboxflg)
		{
		if (i==0) return(BOT);
		if (i>=nlin) return(TOP);
		return(THRU);
		}
	if (c>=ncol)
		return(0);
	}
ku = i>0 ? lefdata(i-1,c) : 0;
if (i+1 >= nlin)
	kl=0;
else
kl = lefdata(allh(i) ? i+1 : i, c);
if (ku==2 && kl==2) return(THRU);
if (ku ==2) return(TOP);
if (kl==BOT) return(2);
return(0);
}
Exemplo n.º 2
0
interh(i,c)
{
int kl, kr;
if (fullbot[i]== '=' || (dboxflg && (i==0 || i>= nlin-1)))
	{
	if (c==ncol)
		return(LEFT);
	if (c==0)
		return(RIGHT);
	return(THRU);
	}
if (i>=nlin) return(0);
kl = c>0 ? thish (i,c-1) : 0;
if (kl<=1 && i>0 && allh(up1(i)))
	kl = c>0 ? thish(up1(i),c-1) : 0;
kr = thish(i,c);
if (kr<=1 && i>0 && allh(up1(i)))
	kr = c>0 ? thish(up1(i), c) : 0;
if (kl== '=' && kr ==  '=') return(THRU);
if (kl== '=') return(LEFT);
if (kr== '=') return(RIGHT);
return(0);
}
Exemplo n.º 3
0
Arquivo: t7.c Projeto: andreiw/polaris
void
need(void)
{
	int texlin, horlin, i;

	for(texlin = horlin = i = 0; i < nlin; i++) {
		if (allh(i))
			horlin++;
		else if (instead[i] != 0)
			continue;
		else
			texlin++;
	}
	(void) fprintf(tabout, ".ne %dv+%dp\n", texlin, 2 * horlin);
	/*
	 * For nroff runs, we need to reserve space for the full height of the
	 * horizontal rules.  If we don't reserve sufficient height, we'll have
	 * problems trying to draw the vertical lines across the page boundary.
	 */
	(void) fprintf(tabout, ".if n .ne %dv\n", 2 * texlin + 2 * horlin + 2);
}
Exemplo n.º 4
0
void
drawline(int i, int cl, int cr, int lintype, int noheight, int shortl)
{
	char *exhr, *exhl, *lnch;
	int lcount, ln, linpos, oldpos, nodata;
lcount=0;
exhr=exhl= "";
switch(lintype)
	{
	case '-': lcount=1;break;
	case '=': lcount = pr1403? 1 : 2; break;
	case SHORTLINE: lcount=1; break;
	}
if (lcount<=0) return;
nodata = cr-cl>=ncol || noheight || allh(i);
	if (!nodata)
		fprintf(tabout, "\\v'-.5m'");
for(ln=oldpos=0; ln<lcount; ln++)
	{
	linpos = 2*ln - lcount +1;
	if (linpos != oldpos)
		fprintf(tabout, "\\v'%dp'", linpos-oldpos);
	oldpos=linpos;
	if (shortl==0)
	{
	tohcol(cl);
	if (lcount>1)
		{
		switch(interv(i,cl))
			{
			case TOP: exhl = ln==0 ? "1p" : "-1p"; break;
			case BOT: exhl = ln==1 ? "1p" : "-1p"; break;
			case THRU: exhl = "1p"; break;
			}
		if (exhl[0])
		fprintf(tabout, "\\h'%s'", exhl);
		}
	else if (lcount==1)
		{
		switch(interv(i,cl))
			{
			case TOP: case BOT: exhl = "-1p"; break;
			case THRU: exhl = "1p"; break;
			}
		if (exhl[0])
		fprintf(tabout, "\\h'%s'", exhl);
		}
	if (lcount>1)
		{
		switch(interv(i,cr+1))
			{
			case TOP: exhr = ln==0 ? "-1p" : "+1p"; break;
			case BOT: exhr = ln==1 ? "-1p" : "+1p"; break;
			case THRU: exhr = "-1p"; break;
			}
		}
	else if (lcount==1)
		{
		switch(interv(i,cr+1))
			{
			case TOP: case BOT: exhr = "+1p"; break;
			case THRU: exhr = "-1p"; break;
			}
		}
	}
	else
		fprintf(tabout, "\\h'|\\n(%du'", cl+CLEFT);
	fprintf(tabout, "\\s\\n(%d",LSIZE);
	if (linsize)
		fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE);
	if (shortl)
		fprintf(tabout, "\\l'|\\n(%du'", cr+CRIGHT);
	else
	{
	lnch = "\\(ul";
	if (pr1403)
		lnch = lintype==2 ? "=" : "\\(ru";
	if (cr+1>=ncol)
		fprintf(tabout, "\\l'|\\n(TWu%s%s'", exhr,lnch);
	else
		fprintf(tabout, "\\l'(|\\n(%du+|\\n(%du)/2u%s%s'", cr+CRIGHT,
			cr+1+CLEFT, exhr, lnch);
	}
	if (linsize)
		fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE);
	fprintf(tabout, "\\s0");
	}
if (oldpos!=0)
	fprintf(tabout, "\\v'%dp'", -oldpos);
if (!nodata)
	fprintf(tabout, "\\v'+.5m'");
}
Exemplo n.º 5
0
drawvert(start,end, c, lwid)
{
char *exb=0, *ext=0;
int tp=0, sl, ln, pos, epb, ept, vm;
end++;
vm='v';
/* note: nr 35 has value of 1m outside of linesize */
while (instead[end]) end++;
for(ln=0; ln<lwid; ln++)
	{
	epb=ept=0;
	pos = 2*ln-lwid+1;
	if (pos!=tp) fprintf(tabout, "\\h'%dp'", pos-tp);
	tp = pos;
	if (end<nlin)
		{
		if (fullbot[end]|| (!instead[end] && allh(end)))
			epb=2;
		else
		switch (midbar(end,c))
			{
			case '-':
			exb = "1v-.5m"; break;
			case '=':
			exb = "1v-.5m";
			epb = 1; break;
			}
		}
	if (lwid>1)
	switch(interh(end, c))
		{
		case THRU: epb -= 1; break;
		case RIGHT: epb += (ln==0 ? 1 : -1); break;
		case LEFT: epb += (ln==1 ? 1 : -1); break;
		}
	if (lwid==1)
	switch(interh(end,c))
		{
		case THRU: epb -= 1; break;
		case RIGHT: case LEFT: epb += 1; break;
		}
	if (start>0)
		{
		sl = start-1;
		while (sl>=0 && instead[sl]) sl--;
		if (sl>=0 && (fullbot[sl] || allh(sl)))
			ept=0;
		else
		if (sl>=0)
		switch(midbar(sl,c))
			{
			case '-':
			ext = ".5m"; break;
			case '=':
			ext= ".5m"; ept = -1; break;
			default:
				vm = 'm'; break;
			}
		else
			ept = -4;
		}
	else if (start==0 && allh(0))
		{
		ept=0;
		vm = 'm';
		}
	if (lwid>1)
		switch(interh(start,c))
			{
			case THRU: ept += 1; break;
			case LEFT: ept += (ln==0 ? 1 : -1); break;
			case RIGHT: ept += (ln==1 ? 1 : -1); break;
			}
	else if (lwid==1)
		switch(interh(start,c))
			{
			case THRU: ept += 1; break;
			case LEFT: case RIGHT: ept -= 1; break;
			}
	if (exb)
		fprintf(tabout, "\\v'%s'", exb);
	if (epb)
		fprintf(tabout, "\\v'%dp'", epb);
	fprintf(tabout, "\\s\\n(%d",LSIZE);
	if (linsize)
		fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE);
	fprintf(tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */
	fprintf(tabout, "\\L'|\\n(#%cu-%s", linestop[start]+'a'-1, vm=='v'? "1v" : "\\n(35u");
	if (ext)
		fprintf(tabout, "-(%s)",ext);
	if (exb)
		fprintf(tabout, "-(%s)", exb);
	pos = ept-epb;
	if (pos)
		fprintf(tabout, "%s%dp", pos>=0? "+" : "", pos);
	/* the string #d is either "nl" or ".d" depending
	   on diversions; on GCOS not the same */
	fprintf(tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s", linestop[start]+'a'-1,vm=='v' ? "1v" : "\\n(35u");
	if (ext)
		fprintf(tabout, "+%s",ext);
	if (ept)
		fprintf(tabout, "%s%dp", (-ept)>0 ? "+" : "", (-ept));
	fprintf(tabout, "'");
	if (linsize)
		fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE);
	}
}
Exemplo n.º 6
0
void
drawline(int i, int cl, int cr, int lintype, int noheight, int shortl)
{
	const char *exhr, *exhl, *lnch;
	int lcount, ln, linpos, oldpos, nodata;
	lcount=0;
	exhr=exhl= "";
	switch(lintype)
	{
	case '-': lcount=1;break;
	case '=': lcount = nflm ? 1 : 2; break;
	case SHORTLINE: lcount=1; break;
	}
	if (lcount<=0) return;
	nodata = cr-cl>=ncol || noheight || allh(i);
	if (!nflm) {
		if (!nodata)
			fprintf(tabout, "\\v'-.5m'");
		if (graphics)
			fprintf(tabout, "\\v'\\n(#Du'");
	}
	for(ln=oldpos=0; ln<lcount; ln++)
	{
		linpos = 2*ln - lcount +1;
		if (linpos != oldpos)
			fprintf(tabout, "\\v'%dp'", linpos-oldpos);
		oldpos=linpos;
		if (shortl==0)
		{
			tohcol(cl);
			if (lcount>1)
			{
				switch(interv(i,cl))
				{
				case TOP: exhl = ln==0 ? "1p" : "-1p"; break;
				case BOT: exhl = ln==1 ? "1p" : "-1p"; break;
				case THRU: exhl = "1p"; break;
				}
				if (exhl[0])
					fprintf(tabout, "\\h'%s'", exhl);
			}
			else if (lcount==1)
			{
				switch(interv(i,cl))
				{
				case TOP: case BOT: exhl = "-1p"; break;
				case THRU: exhl = "1p"; break;
				}
				if (exhl[0])
					fprintf(tabout, "\\h'%s'", exhl);
			}
			if (lcount>1)
			{
				switch(interv(i,cr+1))
				{
				case TOP: exhr = ln==0 ? "-1p" : "+1p"; break;
				case BOT: exhr = ln==1 ? "-1p" : "+1p"; break;
				case THRU: exhr = "-1p"; break;
				}
			}
			else if (lcount==1)
			{
				switch(interv(i,cr+1))
				{
				case TOP: case BOT: exhr = "+1p"; break;
				case THRU: exhr = "-1p"; break;
				}
			}
		}
		else
			fprintf(tabout, "\\h'|\\n(%du'", cl+CLEFT);
		if (!graphics)
			fprintf(tabout, "\\s\\n(%d",LSIZE);
		if (linsize)
			fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE);
		if (shortl) {
			if (graphics)
				fprintf(tabout, "\\D'l |\\n(%du 0'", cr+CRIGHT);
			else
				fprintf(tabout, "\\l'|\\n(%du%s'", cr+CRIGHT,
				    utf8 ?  "\\U'2500'" : /* ─ */
				    tlp  ?  "\\-"       :
				            "");
		}
		else if (graphics) {
			if (cr+1>=ncol)
				fprintf(tabout, "\\D'l |\\n(TWu%s 0'", exhr);
			else
				fprintf(tabout, "\\D'l (|\\n(%du+|\\n(%du)/2u%s 0'",
						cr+CRIGHT, cr+1+CLEFT, exhr);
		}
		else
		{
			lnch = "\\(ul";
			if (utf8)
				lnch = lintype == '=' ? "\\U'2550'" : /* ═ */
				                        "\\U'2500'" ; /* ─ */
			else if (tlp)
				lnch = lintype == '=' ? "\\&=" : "\\-";
			else
			if (pr1403)
				lnch = lintype == '=' ? "\\&=" : "\\(ru";
			if (cr+1>=ncol)
				fprintf(tabout, "\\l'|\\n(TWu%s%s'", exhr,lnch);
			else
				fprintf(tabout, "\\l'(|\\n(%du+|\\n(%du)/2u%s%s'", cr+CRIGHT,
					cr+1+CLEFT, exhr, lnch);
		}
		if (linsize)
			fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE);
		if (!graphics)
			fprintf(tabout, "\\s0");
	}
	if (oldpos!=0)
		fprintf(tabout, "\\v'%dp'", -oldpos);
	if (graphics)
		fprintf(tabout, "\\v'-\\n(#Du'");
	if (!nodata)
		fprintf(tabout, "\\v'+.5m'");
	if (!shortl && (utf8 || tlp)) {
		int corred, c, ccr, licr;
		const char *s;
		ccr = cr;
		if (ccr == cl) ccr++;
		corred = 0;
		if (ccr == ncol && (boxflg || allflg || dboxflg) &&
		    (s = grbe(i, lintype))) {
			fprintf(tabout, "\n.sp -1\n");
			corred = 1;
			fprintf(tabout, "\\h'|\\n(TWu'");
			fprintf(tabout, "%s", s);
		}
		licr = ccr;
		if (licr == ncol) {
			licr--;
			if (!(boxflg || allflg || dboxflg)) ccr--;
		}
		for(c = cl; c <= licr; c++) {
			if ((s = glibe(i, c, cl, ccr, lintype))) {
				if (!corred) {
					fprintf(tabout, "\n.sp -1\n");
					corred = 1;
				}
				tohcol(c);
				fprintf(tabout, "%s", s);
			}
		}
	}
}
Exemplo n.º 7
0
/*
 * parameters
 *
 * i:	line number for deciding format
 * nl:	line number for finding data   usually identical
 */
void
putline(int i, int nl)
{
int c, lf, ct, form, lwid, vspf, ip = -1, cmidx, exvspen, vforml;
int vct, chfont;
char *s, *size, *fn;
watchout=vspf=exvspen=0;
if (i==0) once=0;
if (i==0 && ( allflg || boxflg || dboxflg))
	fullwide(0,   dboxflg? '=' : '-');
if (instead[nl]==0 && fullbot[nl] ==0)
for(c=0; c<ncol; c++)
	{
	s = table[nl][c].col;
	if (s==0) continue;
	if (vspen(s))
		{
		for(ip=nl; ip<nlin; ip=next(ip))
			if (!vspen(s=table[ip][c].col)) break;
		if (s>(char *)0 && s<(char *)128)
		fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
		continue;
		}
	if (point(s)) continue;
	fprintf(tabout, ".ne \\n(%c|u+\\n(.Vu\n",s);
	watchout=1;
	}
if (linestop[nl])
	fprintf(tabout, ".mk #%c\n", linestop[nl]+'a'-1);
lf = prev(nl);
if (instead[nl])
	{
	puts(instead[nl]);
	return;
	}
if (fullbot[nl])
	{
	switch (ct=fullbot[nl])
		{
		case '=':
		case '-':
			fullwide(nl,ct);
		}
	return;
	}
for(c=0; c<ncol; c++)
	{
	if (instead[nl]==0 && fullbot[nl]==0)
	if (vspen(table[nl][c].col)) vspf=1;
	if (lf>=0)
		if (vspen(table[lf][c].col)) vspf=1;
	}
if (vspf)
	{
	fprintf(tabout, ".nr #^ \\n(\\*(#du\n");
	fprintf(tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
	}
vspf=0;
chfont=0;
for(c=0; c<ncol; c++)
	{
	s = table[nl][c].col;
	if (s==0) continue;
	chfont |= (int)(font[stynum[nl]][c]);
	if (point(s) ) continue;
	lf=prev(nl);
	if (lf>=0 && vspen(table[lf][c].col))
		fprintf(tabout, ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",s,'a'+c,s,'a'+c);
	else
		fprintf(tabout, ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",s,s);
	}
if (allflg && once>0 )
	fullwide(i,'-');
once=1;
runtabs(i, nl);
if (allh(nl) && !pr1403)
	{
	fprintf(tabout, ".nr %d \\n(.v\n", SVS);
	fprintf(tabout, ".vs \\n(.vu-\\n(.sp\n");
	}
if (chfont)
	fprintf(tabout, ".nr %2d \\n(.f\n", S1);
fprintf(tabout, ".nr 35 1m\n");
fprintf(tabout, "\\&");
vct = 0;
for(c=0; c<ncol; c++)
	{
	if (watchout==0 && i+1<nlin && (lf=left(i,c, &lwid))>=0)
		{
		tohcol(c);
		drawvert(lf, i, c, lwid);
		vct += 2;
		}
	if (rightl && c+1==ncol) continue;
	vforml=i;
	for(lf=prev(nl); lf>=0 && vspen(table[lf][c].col); lf=prev(lf))
		vforml= lf;
	form= ctype(vforml,c);
	if (form != 's')
		{
		ct = c+CLEFT;
		if (form=='a') ct = c+CMID;
		if (form=='n' && table[nl][c].rcol && lused[c]==0) ct= c+CMID;
		fprintf(tabout, "\\h'|\\n(%du'", ct);
		}
	s= table[nl][c].col;
	fn = font[stynum[vforml]][c];
	size = csize[stynum[vforml]][c];
	if (*size==0)size=0;
	switch(ct=ctype(vforml, c))
		{
		case 'n':
		case 'a':
			if (table[nl][c].rcol)
				{
			   if (lused[c]) /*Zero field width*/
				{
				ip = prev(nl);
				if (ip>=0)
				if (vspen(table[ip][c].col))
					{
					if (exvspen==0)
						{
						fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
						if (cmidx)
							fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
						vct++;
						fprintf(tabout, "'");
						exvspen=1;
						}
					}
				fprintf(tabout, "%c%c",F1,F2);
				puttext(s,fn,size);
				fprintf(tabout, "%c",F1);
				}
				s= table[nl][c].rcol;
				form=1;
				break;
				}
			/* FALLTHROUGH */
		case 'c':
			form=3; break;
		case 'r':
			form=2; break;
		case 'l':
			form=1; break;
		case '-':
		case '=':
			if (real(table[nl][c].col))
				fprintf(stderr,gettext("%s: line %d: Data ignored on table line %d\n"), ifile, iline-1, i+1);
			makeline(i,c,ct);
			continue;
		default:
			continue;
		}
	if (realsplit ? rused[c]: used[c]) /*Zero field width*/
		{
		/* form: 1 left, 2 right, 3 center adjust */
		if (ifline(s))
			{
			makeline(i,c,ifline(s));
			continue;
			}
		if (filler(s))
			{
			printf("\\l'|\\n(%du\\&%s'", c+CRIGHT, s+2);
			continue;
			}
		ip = prev(nl);
		cmidx = ctop[stynum[nl]][c]==0;
		if (ip>=0)
		if (vspen(table[ip][c].col))
			{
			if (exvspen==0)
				{
				fprintf(tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c+'a');
				if (cmidx)
					fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
				vct++;
				fprintf(tabout, "'");
				}
			}
		fprintf(tabout, "%c", F1);
		if (form!= 1)
			fprintf(tabout, "%c", F2);
		if (vspen(s))
			vspf=1;
		else
		puttext(s, fn, size);
		if (form !=2)
			fprintf(tabout, "%c", F2);
		fprintf(tabout, "%c", F1);
		}
	if (ip>=0)
	if (vspen(table[ip][c].col))
		{
		exvspen = (c+1 < ncol) && vspen(table[ip][c+1].col) &&
			(topat[c] == topat[c+1]) &&
			(cmidx == (ctop [stynum[nl]][c+1]==0)) && (left(i,c+1,&lwid)<0);
		if (exvspen==0)
			{
			fprintf(tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c+'a');
			if (cmidx)
				fprintf(tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c+'a');
			vct++;
			fprintf(tabout, "'");
			}
		}
	else
		exvspen=0;
	/* if lines need to be split for gcos here is the place for a backslash */
	if (vct > 7 && c < ncol)
		{
		fprintf(tabout, "\n.sp-1\n\\&");
		vct=0;
		}
	}
fprintf(tabout, "\n");
if (allh(nl) && !pr1403) fprintf(tabout, ".vs \\n(%du\n", SVS);
if (watchout)
	funnies(i,nl);
if (vspf)
	{
	for(c=0; c<ncol; c++)
		if (vspen(table[nl][c].col) && (nl==0 || (lf=prev(nl))<0 || !vspen(table[lf][c].col)))
			{
			fprintf(tabout, ".nr ^%c \\n(#^u\n", 'a'+c);
			topat[c]=nl;
			}
	}
}