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 if (!vspen(ss = table[ip][c].col))
32 Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", (int)s);
38 Bprint(&tabout, ".ne \\n(%c|u+\\n(.Vu\n", s);
42 Bprint(&tabout, ".mk #%c\n", linestop[nl] + 'a' - 1);
45 Bprint(&tabout, "%s\n", instead[nl]);
49 switch (ct = fullbot[nl]) {
56 for (c = 0; c < ncol; c++) {
57 if (instead[nl] == 0 && fullbot[nl] == 0)
58 if (vspen(table[nl][c].col))
61 if (vspen(table[lf][c].col))
65 Bprint(&tabout, ".nr #^ \\n(\\*(#du\n");
66 Bprint(&tabout, ".nr #- \\n(#^\n"); /* current line position relative to bottom */
70 for (c = 0; c < ncol; c++) {
71 ss = table[nl][c].col;
74 if(font[c][stynum[nl]])
80 if (lf >= 0 && vspen(table[lf][c].col))
82 ".if (\\n(%c|+\\n(^%c-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(^%c-\\n(#--1v)\n",
83 s, 'a' + c, s, 'a' + c);
86 ".if (\\n(%c|+\\n(#^-1v)>\\n(#- .nr #- +(\\n(%c|+\\n(#^-\\n(#--1v)\n",
89 if (allflg && once > 0 )
93 if (allh(i) && !pr1403) {
94 Bprint(&tabout, ".nr %d \\n(.v\n", SVS);
95 Bprint(&tabout, ".vs \\n(.vu-\\n(.sp\n");
96 Bprint(&tabout, ".nr 35 \\n(.vu\n");
98 Bprint(&tabout, ".nr 35 1m\n");
100 Bprint(&tabout, ".nr %2d \\n(.f\n", S1);
101 Bprint(&tabout, "\\&");
103 for (c = 0; c < ncol; c++) {
105 if (watchout == 0 && i + 1 < nlin && (lf = left(i, c, &lwid)) >= 0) {
107 drawvert(lf, i, c, lwid);
110 if (rightl && c + 1 == ncol)
113 for (lf = prev(nl); lf >= 0 && vspen(table[lf][c].col); lf = prev(lf))
115 form = ctype(vforml, c);
120 if (form == 'n' && table[nl][c].rcol && lused[c] == 0)
122 Bprint(&tabout, "\\h'|\\n(%2su'", rct);
124 ss = table[nl][c].col;
125 fn = font[c][stynum[vforml]];
126 size = csize[c][stynum[vforml]];
129 if ((flags[c][stynum[nl]] & HALFUP) != 0 && pr1403 == 0)
131 switch (ct = ctype(vforml, c)) {
134 if (table[nl][c].rcol) {
135 if (lused[c]) /*Zero field width*/ {
138 if (vspen(table[ip][c].col)) {
140 Bprint(&tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
142 /* code folded from here */
143 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
146 if (pr1403) /* must round to whole lines */
147 /* code folded from here */
148 Bprint(&tabout, "/1v*1v");
150 Bprint(&tabout, "'");
154 Bprint(&tabout, "%c%c", F1, F2);
156 Bprint(&tabout, "\\u");
157 puttext(ss, fn, size);
159 Bprint(&tabout, "\\d");
160 Bprint(&tabout, "%c", F1);
162 ss = table[nl][c].rcol;
177 if (real(table[nl][c].col))
178 fprint(2, "%s: line %d: Data ignored on table line %d\n", ifile, iline - 1, i + 1);
184 if (realsplit ? rused[c] : used[c]) /*Zero field width*/ {
185 /* form: 1 left, 2 right, 3 center adjust */
187 makeline(i, c, ifline(ss));
191 Bprint(&tabout, "\\l'|\\n(%2su\\&%s'", reg(c, CRIGHT), ss + 2);
195 cmidx = (flags[c][stynum[nl]] & (CTOP | CDOWN)) == 0;
197 if (vspen(table[ip][c].col)) {
199 Bprint(&tabout, "\\v'-(\\n(\\*(#du-\\n(^%cu", c + 'a');
201 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
203 if (pr1403) /* round to whole lines */
204 Bprint(&tabout, "/1v*1v");
205 Bprint(&tabout, "'");
208 Bprint(&tabout, "%c", F1);
210 Bprint(&tabout, "%c", F2);
216 Bprint(&tabout, "\\u");
217 puttext(ss, fn, size);
219 Bprint(&tabout, "\\d");
222 Bprint(&tabout, "%c", F2);
223 Bprint(&tabout, "%c", F1);
227 if (vspen(table[ip][c].col)) {
228 exvspen = (c + 1 < ncol) && vspen(table[ip][c+1].col) &&
229 (topat[c] == topat[c+1]) &&
230 (cmidx == (flags[c+1] [stynum[nl]] & (CTOP | CDOWN) == 0))
231 && (left(i, c + 1, &lwid) < 0);
233 Bprint(&tabout, "\\v'(\\n(\\*(#du-\\n(^%cu", c + 'a');
235 Bprint(&tabout, "-((\\n(#-u-\\n(^%cu)/2u)", c + 'a');
237 if (pr1403) /* round to whole lines */
238 Bprint(&tabout, "/1v*1v");
239 Bprint(&tabout, "'");
244 /* if lines need to be split for gcos here is the place for a backslash */
245 if (vct > 7 && c < ncol) {
246 Bprint(&tabout, "\n.sp-1\n\\&");
250 Bprint(&tabout, "\n");
251 if (allh(i) && !pr1403)
252 Bprint(&tabout, ".vs \\n(%du\n", SVS);
256 for (c = 0; c < ncol; c++)
257 if (vspen(table[nl][c].col) && (nl == 0 || (lf = prev(nl)) < 0 ||
258 !vspen(table[lf][c].col))) {
259 Bprint(&tabout, ".nr ^%c \\n(#^u\n", 'a' + c);
267 puttext(char *s, char *fn, char *size)
272 Bprint(&tabout, "%s", s);
274 Bprint(&tabout, "\\f\\n(%2d", S1);
282 funnies(int stl, int lin)
284 /* write out funny diverted things */
285 int c, s, pl, lwid, dv, lf, ct;
288 Bprint(&tabout, ".mk ##\n"); /* rmember current vertical position */
289 Bprint(&tabout, ".nr %d \\n(##\n", S1); /* bottom position */
290 for (c = 0; c < ncol; c++) {
291 ss = table[lin][c].col;
296 s = (int)(uintptr)ss;
297 Bprint(&tabout, ".sp |\\n(##u-1v\n");
298 Bprint(&tabout, ".nr %d ", SIND);
300 for (pl = stl; pl >= 0 && !isalpha(ct = ctype(pl, c)); pl = prev(pl))
305 Bprint(&tabout, "(\\n(%2su+\\n(%2su-\\n(%c-u)/2u\n", reg(c, CLEFT),
306 reg(c - 1 + ctspan(lin, c), CRIGHT),
310 Bprint(&tabout, "\\n(%2su\n", reg(c, CLEFT));
313 Bprint(&tabout, "\\n(%2su\n", reg(c, CMID));
316 Bprint(&tabout, "\\n(%2su-\\n(%c-u\n", reg(c, CRIGHT), s);
319 Bprint(&tabout, ".in +\\n(%du\n", SIND);
320 fn = font[c][stynum[stl]];
323 if (stl > 0 && pl >= 0 && vspen(table[pl][c].col)) {
324 Bprint(&tabout, ".sp |\\n(^%cu\n", 'a' + c);
325 if ((flags[c][stynum[stl]] & (CTOP | CDOWN)) == 0) {
326 Bprint(&tabout, ".nr %d \\n(#-u-\\n(^%c-\\n(%c|+1v\n",
328 Bprint(&tabout, ".if \\n(%d>0 .sp \\n(%du/2u", TMP, TMP);
329 if (pr1403) /* round */
330 Bprint(&tabout, "/1v*1v");
331 Bprint(&tabout, "\n");
334 Bprint(&tabout, ".%c+\n", s);
335 Bprint(&tabout, ".in -\\n(%du\n", SIND);
338 Bprint(&tabout, ".mk %d\n", S2);
339 Bprint(&tabout, ".if \\n(%d>\\n(%d .nr %d \\n(%d\n", S2, S1, S1, S2);
341 Bprint(&tabout, ".sp |\\n(%du\n", S1);
342 for (c = dv = 0; c < ncol; c++) {
343 if (stl + 1 < nlin && (lf = left(stl, c, &lwid)) >= 0) {
345 Bprint(&tabout, ".sp -1\n");
348 drawvert(lf, stl, c, lwid);
352 Bprint(&tabout, "\n");
360 Bprint(&tabout, fn[1] ? "\\f(%.2s" : "\\f%.2s", fn);
368 Bprint(&tabout, "\\s%s", s);