xref: /csrg-svn/old/tbl/tg.c (revision 48316)
1*48316Sbostic /*-
2*48316Sbostic  * %sccs.include.proprietary.c%
3*48316Sbostic  */
4*48316Sbostic 
514514Ssam #ifndef lint
6*48316Sbostic static char sccsid[] = "@(#)tg.c	4.3 (Berkeley) 04/18/91";
7*48316Sbostic #endif /* not lint */
811041Sshannon 
911041Sshannon  /* tg.c: process included text blocks */
1011041Sshannon # include "t..c"
gettext(sp,ilin,icol,fn,sz)1111041Sshannon gettext(sp, ilin,icol, fn, sz)
1211041Sshannon 	char *sp, *fn, *sz;
1311041Sshannon {
1411041Sshannon /* get a section of text */
1511041Sshannon char line[256];
1611041Sshannon int oname;
1711041Sshannon char *vs;
1811041Sshannon if (texname==0) error("Too many text block diversions");
1911041Sshannon if (textflg==0)
2011041Sshannon 	{
2111041Sshannon 	fprintf(tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
2211041Sshannon 	textflg=1;
2311041Sshannon 	}
2411041Sshannon fprintf(tabout, ".eo\n");
2511041Sshannon fprintf(tabout, ".am %02d\n", icol+80);
2611041Sshannon fprintf(tabout, ".br\n");
2711041Sshannon fprintf(tabout, ".di %c+\n", texname);
2811041Sshannon rstofill();
2911041Sshannon if (fn && *fn) fprintf(tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
3011041Sshannon fprintf(tabout, ".ft \\n(.f\n"); /* protect font */
3111041Sshannon vs = vsize[stynum[ilin]][icol];
3211041Sshannon if ((sz && *sz) || (vs && *vs))
3311041Sshannon 	{
3411041Sshannon 	fprintf(tabout, ".nr %d \\n(.v\n", S2);
3511041Sshannon 	if (vs==0 || *vs==0) vs= "\\n(.s+2";
3611041Sshannon 	if (sz && *sz)
3711041Sshannon 		fprintf(tabout, ".ps %s\n",sz);
3811041Sshannon 	fprintf(tabout, ".vs %s\n",vs);
3911041Sshannon 	fprintf(tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S2,S2);
4011041Sshannon 	}
4111041Sshannon if (cll[icol][0])
4211041Sshannon 	fprintf(tabout, ".ll %sn\n", cll[icol]);
4311041Sshannon else
4411041Sshannon 	fprintf(tabout, ".ll \\n(%du*%du/%du\n",SL,ctspan(ilin,icol),ncol+1);
4511041Sshannon fprintf(tabout,".if \\n(.l<\\n(%d .ll \\n(%du\n", icol+CRIGHT, icol+CRIGHT);
4611041Sshannon if (ctype(ilin,icol)=='a')
4711041Sshannon 	fprintf(tabout, ".ll -2n\n");
4811041Sshannon fprintf(tabout, ".in 0\n");
4911041Sshannon while (gets1(line))
5011041Sshannon 	{
5111041Sshannon 	if (line[0]=='T' && line[1]=='}' && line[2]== tab) break;
5211041Sshannon 	if (match("T}", line)) break;
5311041Sshannon 	fprintf(tabout, "%s\n", line);
5411041Sshannon 	}
5511041Sshannon if (fn && *fn) fprintf(tabout, ".ft \\n(%d\n", S1);
5611041Sshannon if (sz && *sz) fprintf(tabout, ".br\n.ps\n.vs\n");
5711041Sshannon fprintf(tabout, ".br\n");
5811041Sshannon fprintf(tabout, ".di\n");
5911041Sshannon fprintf(tabout, ".nr %c| \\n(dn\n", texname);
6011041Sshannon fprintf(tabout, ".nr %c- \\n(dl\n", texname);
6111041Sshannon fprintf(tabout, "..\n");
6211041Sshannon fprintf(tabout, ".ec \\\n");
6311041Sshannon /* copy remainder of line */
6411041Sshannon if (line[2])
6511041Sshannon 	tcopy (sp, line+3);
6611041Sshannon else
6711041Sshannon 	*sp=0;
6811041Sshannon oname=texname;
6911041Sshannon texname = texstr[++texct];
7011041Sshannon return(oname);
7111041Sshannon }
untext()7211041Sshannon untext()
7311041Sshannon {
7411041Sshannon rstofill();
7511041Sshannon fprintf(tabout, ".nf\n");
7611041Sshannon fprintf(tabout, ".ll \\n(%du\n", SL);
7711041Sshannon }
78