ttg.c - plan9port - [fork] Plan 9 from user space
 (HTM) git clone git://src.adamsgaard.dk/plan9port
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
       ttg.c (2155B)
       ---
            1 /* tg.c: process included text blocks */
            2 # include "t.h"
            3 
            4 int
            5 gettext(char *sp, int ilin, int icol, char *fn, char *sz)
            6 {
            7                                         /* get a section of text */
            8         char        line[4096];
            9         int        oname, startline;
           10         char        *vs;
           11 
           12         startline = iline;
           13         if (texname == 0)
           14                 error("Too many text block diversions");
           15         if (textflg == 0) {
           16                 Bprint(&tabout, ".nr %d \\n(.lu\n", SL); /* remember old line length */
           17                 textflg = 1;
           18         }
           19         Bprint(&tabout, ".eo\n");
           20         Bprint(&tabout, ".am %s\n", reg(icol, CRIGHT));
           21         Bprint(&tabout, ".br\n");
           22         Bprint(&tabout, ".di %c+\n", texname);
           23         rstofill();
           24         if (fn && *fn)
           25                 Bprint(&tabout, ".nr %d \\n(.f\n.ft %s\n", S1, fn);
           26         Bprint(&tabout, ".ft \\n(.f\n"); /* protect font */
           27         vs = vsize[icol][stynum[ilin]];
           28         if ((sz && *sz) || (vs && *vs)) {
           29                 Bprint(&tabout, ".nr %d \\n(.v\n", S9);
           30                 if (vs == 0 || *vs == 0)
           31                         vs = "\\n(.s+2";
           32                 if (sz && *sz)
           33                         Bprint(&tabout, ".ps %s\n", sz);
           34                 Bprint(&tabout, ".vs %s\n", vs);
           35                 Bprint(&tabout, ".if \\n(%du>\\n(.vu .sp \\n(%du-\\n(.vu\n", S9, S9);
           36         }
           37         if (cll[icol][0])
           38                 Bprint(&tabout, ".ll %sn\n", cll[icol]);
           39         else
           40                 Bprint(&tabout, ".ll \\n(%du*%du/%du\n", SL, ctspan(ilin, icol), ncol + 1);
           41         Bprint(&tabout, ".if \\n(.l<\\n(%2s .ll \\n(%2su\n", reg(icol, CRIGHT),
           42              reg(icol, CRIGHT));
           43         if (ctype(ilin, icol) == 'a')
           44                 Bprint(&tabout, ".ll -2n\n");
           45         Bprint(&tabout, ".in 0\n");
           46         for (;;) {
           47                 if (gets1(line, sizeof(line)) == nil) {
           48                         iline = startline;
           49                         error("missing closing T}");
           50                 }
           51                 if (line[0] == 'T' && line[1] == '}' && line[2] == tab)
           52                         break;
           53                 if (match("T}", line))
           54                         break;
           55                 Bprint(&tabout, "%s\n", line);
           56         }
           57         if (fn && *fn)
           58                 Bprint(&tabout, ".ft \\n(%d\n", S1);
           59         if (sz && *sz)
           60                 Bprint(&tabout, ".br\n.ps\n.vs\n");
           61         Bprint(&tabout, ".br\n");
           62         Bprint(&tabout, ".di\n");
           63         Bprint(&tabout, ".nr %c| \\n(dn\n", texname);
           64         Bprint(&tabout, ".nr %c- \\n(dl\n", texname);
           65         Bprint(&tabout, "..\n");
           66         Bprint(&tabout, ".ec \\\n");
           67         /* copy remainder of line */
           68         if (line[2])
           69                 tcopy (sp, line + 3);
           70         else
           71                 *sp = 0;
           72         oname = texname;
           73         texname = texstr[++texct];
           74         return(oname);
           75 }
           76 
           77 
           78 void
           79 untext(void)
           80 {
           81         rstofill();
           82         Bprint(&tabout, ".nf\n");
           83         Bprint(&tabout, ".ll \\n(%du\n", SL);
           84 }