1 /* t8.c: write out one line of output table */
3 # define realsplit ((ct=='a'||ct=='n') && table[nl][c].rcol)
9 /* i is line number for deciding format */
10 /* nl is line number for finding data usually identical */
12 int c, s, lf, ct, form, lwid, vspf, ip, cmidx, exvspen, vforml;
13 int vct, chfont, uphalf;
14 char *ss, *size, *fn, *rct;
16 cmidx = watchout = vspf = exvspen = 0;
19 if (i == 0 && ( allflg || boxflg || dboxflg))
20 fullwide(0, dboxflg ? '=' : '-');
21 if (instead[nl] == 0 && fullbot[nl] == 0)
22 for (c = 0; c < ncol; c++) {
23 ss = table[nl][c].col;
27 for (ip = nl; ip < nlin; ip = next(ip)){
28 ss = table[ip][c].col;
34 Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s);
40 Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s);
44 Bprint(&tabout, ".mk #%c\n", linestop[nl] + 'a' - 1);
47 Bprint(&tabout, "%s\n", instead[nl]);
51 switch (ct = fullbot[nl]) {
58 for (c = 0; c < ncol; c++) {
59 if (instead[nl] == 0 && fullbot[nl] == 0)
60 if (vspen(table[nl][c].col))
63 if (vspen(table[lf][c].col))
67 Bprint(&tabout, ".nr #^ \\n(\\*(#du\n");
68 Bprint(&tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
72 for (c = 0; c < ncol; c++) {
73 ss = table[nl][c].col;
76 if(font[c][stynum[nl]])
82 if (lf >= 0 && vspen(table[lf][c].col))
84 ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",
85 s, 'a' + c, s, 'a' + c);
88 ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",
91 if (allflg && once > 0 )
95 if (allh(i) && !pr1403) {
96 Bprint(&tabout, ".nr %d \\n(.v\n", SVS);
97 Bprint(&tabout, ".vs \\n(.vu-\\n(.sp\n");
98 Bprint(&tabout, ".nr 35 \\n(.vu\n");
100 Bprint(&tabout, ".nr 35 1m\n");
102 Bprint(&tabout, ".nr %2d \\n(.f\n", S1);
103 Bprint(&tabout, "\\&");
105 for (c = 0; c < ncol; c++) {
107 if (watchout == 0 && i + 1 < nlin && (lf = left(i, c, &lwid)) >= 0) {
109 drawvert(lf, i, c, lwid);
112 if (rightl && c + 1 == ncol)
115 for (lf = prev(nl); lf >= 0 && vspen(table[lf][c].col); lf = prev(lf))
117 form = ctype(vforml, c);
122 if (form == 'n' && table[nl][c].rcol && lused[c] == 0)
124 Bprint(&tabout, "\\h'|\\n(%2su'", rct);
126 ss = table[nl][c].col;
127 fn = font[c][stynum[vforml]];
128 size = csize[c][stynum[vforml]];
131 if ((flags[c][stynum[nl]] & HALFUP) != 0 && pr1403 == 0)
133 switch (ct = ctype(vforml, c)) {
136 if (table[nl][c].rcol) {
137 if (lused[c]) /*Zero field width*/ {
140 if (vspen(table[ip][c].col)) {
142 Bprint(&tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
144 /* code folded from here */
145 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
148 if (pr1403) /* must round to whole lines */
149 /* code folded from here */
150 Bprint(&tabout, "/1v*1v");
152 Bprint(&tabout, "'");
156 Bprint(&tabout, "%c%c", F1, F2);
158 Bprint(&tabout, "\\u");
159 puttext(ss, fn, size);
161 Bprint(&tabout, "\\d");
162 Bprint(&tabout, "%c", F1);
164 ss = table[nl][c].rcol;
179 if (real(table[nl][c].col))
180 fprint(2, "%s: line %d: Data ignored on table line %d\n", ifile, iline - 1, i + 1);
186 if (realsplit ? rused[c] : used[c]) /*Zero field width*/ {
187 /* form: 1 left, 2 right, 3 center adjust */
189 makeline(i, c, ifline(ss));
193 Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), ss + 2);
197 cmidx = (flags[c][stynum[nl]] & (CTOP | CDOWN)) == 0;
199 if (vspen(table[ip][c].col)) {
201 Bprint(&tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
203 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
205 if (pr1403) /* round to whole lines */
206 Bprint(&tabout, "/1v*1v");
207 Bprint(&tabout, "'");
210 Bprint(&tabout, "%c", F1);
212 Bprint(&tabout, "%c", F2);
218 Bprint(&tabout, "\\u");
219 puttext(ss, fn, size);
221 Bprint(&tabout, "\\d");
224 Bprint(&tabout, "%c", F2);
225 Bprint(&tabout, "%c", F1);
229 if (vspen(table[ip][c].col)) {
230 exvspen = (c + 1 < ncol) && vspen(table[ip][c+1].col) &&
231 (topat[c] == topat[c+1]) &&
232 (cmidx == (flags[c+1] [stynum[nl]] & (CTOP | CDOWN) == 0))
233 && (left(i, c + 1, &lwid) < 0);
235 Bprint(&tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c + 'a');
237 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
239 if (pr1403) /* round to whole lines */
240 Bprint(&tabout, "/1v*1v");
241 Bprint(&tabout, "'");
246 /* if lines need to be split for gcos here is the place for a backslash */
247 if (vct > 7 && c < ncol) {
248 Bprint(&tabout, "\n.sp-1\n\\&");
252 Bprint(&tabout, "\n");
253 if (allh(i) && !pr1403)
254 Bprint(&tabout, ".vs \\n(%du\n", SVS);
258 for (c = 0; c < ncol; c++)
259 if (vspen(table[nl][c].col) && (nl == 0 || (lf = prev(nl)) < 0 ||
260 !vspen(table[lf][c].col))) {
261 Bprint(&tabout, ".nr ^%c \\n(#^u\n", 'a' + c);
269 puttext(char *s, char *fn, char *size)
274 Bprint(&tabout, "%s", s);
276 Bprint(&tabout, "\\f\\n(%2d", S1);
284 funnies(int stl, int lin)
286 /* write out funny diverted things */
287 int c, s, pl, lwid, dv, lf, ct;
290 Bprint(&tabout, ".mk ##\n"); /* rmember current vertical position */
291 Bprint(&tabout, ".nr %d \\n(##\n", S1); /* bottom position */
292 for (c = 0; c < ncol; c++) {
293 ss = table[lin][c].col;
298 s = (int)(uintptr)ss;
299 Bprint(&tabout, ".sp |\\n(##u-1v\n");
300 Bprint(&tabout, ".nr %d ", SIND);
302 for (pl = stl; pl >= 0 && !isalpha(ct = ctype(pl, c)); pl = prev(pl))
307 Bprint(&tabout, "(\\n(%2su+\\n(%2su-\\n(%c-u)/2u\n", reg(c, CLEFT),
308 reg(c - 1 + ctspan(lin, c), CRIGHT),
312 Bprint(&tabout, "\\n(%2su\n", reg(c, CLEFT));
315 Bprint(&tabout, "\\n(%2su\n", reg(c, CMID));
318 Bprint(&tabout, "\\n(%2su-\\n(%c-u\n", reg(c, CRIGHT), s);
321 Bprint(&tabout, ".in +\\n(%du\n", SIND);
322 fn = font[c][stynum[stl]];
325 if (stl > 0 && pl >= 0 && vspen(table[pl][c].col)) {
326 Bprint(&tabout, ".sp |\\n(^%cu\n", 'a' + c);
327 if ((flags[c][stynum[stl]] & (CTOP | CDOWN)) == 0) {
328 Bprint(&tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",
330 Bprint(&tabout, ".if \\n(%d>0 .sp \\n(%du/2u", TMP, TMP);
331 if (pr1403) /* round */
332 Bprint(&tabout, "/1v*1v");
333 Bprint(&tabout, "\n");
336 Bprint(&tabout, ".%c+\n", s);
337 Bprint(&tabout, ".in -\\n(%du\n", SIND);
340 Bprint(&tabout, ".mk %d\n", S2);
341 Bprint(&tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
343 Bprint(&tabout, ".sp |\\n(%du\n", S1);
344 for (c = dv = 0; c < ncol; c++) {
345 if (stl + 1 < nlin && (lf = left(stl, c, &lwid)) >= 0) {
347 Bprint(&tabout, ".sp -1\n");
350 drawvert(lf, stl, c, lwid);
354 Bprint(&tabout, "\n");
362 Bprint(&tabout, fn[1] ? "\\f(%.2s" : "\\f%.2s", fn);
370 Bprint(&tabout, "\\s%s", s);