Commit | Line | Data |
---|---|---|
bf37f301 BS |
1 | /* t7.c 4.1 83/02/12 */ |
2 | ||
3 | /* t7.c: control to write table entries */ | |
4 | # include "t..c" | |
5 | # define realsplit ((ct=='a'||ct=='n') && table[ldata][c].rcol) | |
6 | runout() | |
7 | { | |
8 | int i; | |
9 | if (boxflg || allflg || dboxflg) need(); | |
10 | if (ctrflg) | |
11 | { | |
12 | fprintf(tabout, ".nr #I \\n(.i\n"); | |
13 | fprintf(tabout, ".in +(\\n(.lu-\\n(TWu-\\n(.iu)/2u\n"); | |
14 | } | |
15 | fprintf(tabout, ".fc %c %c\n", F1, F2); | |
16 | fprintf(tabout, ".nr #T 0-1\n"); | |
17 | deftail(); | |
18 | for(i=0; i<nlin; i++) | |
19 | putline(i,i); | |
20 | if (leftover) | |
21 | yetmore(); | |
22 | fprintf(tabout, ".fc\n"); | |
23 | fprintf(tabout, ".nr T. 1\n"); | |
24 | fprintf(tabout, ".T# 1\n"); | |
25 | if (ctrflg) | |
26 | fprintf(tabout, ".in \\n(#Iu\n"); | |
27 | } | |
28 | runtabs(lform, ldata) | |
29 | { | |
30 | int c, ct, vforml, lf; | |
31 | fprintf(tabout, ".ta "); | |
32 | for(c=0; c<ncol; c++) | |
33 | { | |
34 | vforml=lform; | |
35 | for(lf=prev(lform); lf>=0 && vspen(table[lf][c].col); lf=prev(lf)) | |
36 | vforml=lf; | |
37 | if (fspan(vforml,c)) | |
38 | continue; | |
39 | switch(ct=ctype(vforml,c)) | |
40 | { | |
41 | case 'n': | |
42 | case 'a': | |
43 | if (table[ldata][c].rcol) | |
44 | if (lused[c]) /*Zero field width*/ | |
45 | fprintf(tabout, "\\n(%du ",c+CMID); | |
46 | case 'c': | |
47 | case 'l': | |
48 | case 'r': | |
49 | if (realsplit? rused[c]: (used[c]+lused[c])) | |
50 | fprintf(tabout, "\\n(%du ",c+CRIGHT); | |
51 | continue; | |
52 | case 's': | |
53 | if (lspan(lform, c)) | |
54 | fprintf(tabout, "\\n(%du ", c+CRIGHT); | |
55 | continue; | |
56 | } | |
57 | } | |
58 | fprintf(tabout, "\n"); | |
59 | } | |
60 | ifline(s) | |
61 | char *s; | |
62 | { | |
63 | if (s[0] == '\\') s++; | |
64 | if (s[1] ) return(0); | |
65 | if (s[0] == '_') return('-'); | |
66 | if (s[0] == '=') return('='); | |
67 | return(0); | |
68 | } | |
69 | need() | |
70 | { | |
71 | int texlin, horlin, i; | |
72 | for(texlin=horlin=i=0; i<nlin; i++) | |
73 | { | |
74 | if (fullbot[i]!=0) | |
75 | horlin++; | |
76 | else | |
77 | if (instead[i]!=0) | |
78 | continue; | |
79 | else | |
80 | texlin++; | |
81 | } | |
82 | fprintf(tabout, ".ne %dv+%dp\n",texlin,2*horlin); | |
83 | } | |
84 | deftail() | |
85 | { | |
86 | int i, c, lf, lwid; | |
87 | for(i=0; i<MAXHEAD; i++) | |
88 | if (linestop[i]) | |
89 | fprintf(tabout, ".nr #%c 0-1\n", linestop[i]+'a'-1); | |
90 | fprintf(tabout, ".nr #a 0-1\n"); | |
91 | fprintf(tabout, ".eo\n"); | |
92 | fprintf(tabout, ".de T#\n"); | |
93 | fprintf(tabout, ".ds #d .d\n"); | |
94 | fprintf(tabout, ".if \\(ts\\n(.z\\(ts\\(ts .ds #d nl\n"); | |
95 | fprintf(tabout, ".mk ##\n"); | |
96 | fprintf(tabout, ".nr ## -1v\n"); | |
97 | fprintf(tabout, ".ls 1\n"); | |
98 | for(i=0; i<MAXHEAD; i++) | |
99 | if (linestop[i]) | |
100 | fprintf(tabout, ".if \\n(#T>=0 .nr #%c \\n(#T\n",linestop[i]+'a'-1); | |
101 | if (boxflg || allflg || dboxflg) /* bottom of table line */ | |
102 | if (fullbot[nlin-1]==0) | |
103 | { | |
104 | if (!pr1403) | |
105 | fprintf(tabout, ".if \\n(T. .vs \\n(.vu-\\n(.sp\n"); | |
106 | fprintf(tabout, ".if \\n(T. "); | |
107 | drawline(nlin,0,ncol, dboxflg ? '=' : '-',1,0); | |
108 | fprintf(tabout, "\n.if \\n(T. .vs\n"); | |
109 | /* T. is really an argument to a macro but because of | |
110 | eqn we don't dare pass it as an argument and reference by $1 */ | |
111 | } | |
112 | for(c=0; c<ncol; c++) | |
113 | { | |
114 | if ((lf=left(nlin-1,c, &lwid))>=0) | |
115 | { | |
116 | fprintf(tabout, ".if \\n(#%c>=0 .sp -1\n",linestop[lf]+'a'-1); | |
117 | fprintf(tabout, ".if \\n(#%c>=0 ", linestop[lf]+'a'-1); | |
118 | tohcol(c); | |
119 | drawvert(lf, nlin-1, c, lwid); | |
120 | fprintf(tabout, "\\h'|\\n(TWu'\n"); | |
121 | } | |
122 | } | |
123 | if (boxflg || allflg || dboxflg) /* right hand line */ | |
124 | { | |
125 | fprintf(tabout, ".if \\n(#a>=0 .sp -1\n"); | |
126 | fprintf(tabout, ".if \\n(#a>=0 \\h'|\\n(TWu'"); | |
127 | drawvert (0, nlin-1, ncol, dboxflg? 2 : 1); | |
128 | fprintf(tabout, "\n"); | |
129 | } | |
130 | fprintf(tabout, ".ls\n"); | |
131 | fprintf(tabout, "..\n"); | |
132 | fprintf(tabout, ".ec\n"); | |
133 | } |