Commit | Line | Data |
---|---|---|
550f4efd BS |
1 | /* tu.c 4.1 83/02/12 */ |
2 | ||
3 | /* tu.c: draws horizontal lines */ | |
4 | # include "t..c" | |
5 | makeline(i,c,lintype) | |
6 | { | |
7 | int cr, type, shortl; | |
8 | type = thish(i,c); | |
9 | if (type==0) return; | |
10 | cr=c; | |
11 | shortl = (table[i][c].col[0]=='\\'); | |
12 | if (c>0 && !shortl && thish(i,c-1) == type)return; | |
13 | if (shortl==0) | |
14 | for(cr=c; cr < ncol && (ctype(i,cr)=='s'||type==thish(i,cr)); cr++); | |
15 | else | |
16 | for(cr=c+1; cr<ncol && ctype(i,cr)=='s'; cr++); | |
17 | drawline(i, c, cr-1, lintype, 0, shortl); | |
18 | } | |
19 | fullwide(i, lintype) | |
20 | { | |
21 | int cr, cl; | |
22 | if (!pr1403) | |
23 | fprintf(tabout, ".nr %d \\n(.v\n.vs \\n(.vu-\\n(.sp\n", SVS); | |
24 | cr= 0; | |
25 | while (cr<ncol) | |
26 | { | |
27 | cl=cr; | |
28 | while (i>0 && vspand(prev(i),cl,1)) | |
29 | cl++; | |
30 | for(cr=cl; cr<ncol; cr++) | |
31 | if (i>0 && vspand(prev(i),cr,1)) | |
32 | break; | |
33 | if (cl<ncol) | |
34 | drawline(i,cl,(cr<ncol?cr-1:cr),lintype,1,0); | |
35 | } | |
36 | fprintf(tabout, "\n"); | |
37 | if (!pr1403) | |
38 | fprintf(tabout, ".vs \\n(%du\n", SVS); | |
39 | } | |
40 | ||
41 | drawline(i, cl, cr, lintype, noheight, shortl) | |
42 | { | |
43 | char *exhr, *exhl; | |
44 | int lcount, ln, linpos, oldpos, nodata, lnch; | |
45 | lcount=0; | |
46 | exhr=exhl= ""; | |
47 | switch(lintype) | |
48 | { | |
49 | case '-': lcount=1;break; | |
50 | case '=': lcount = pr1403? 1 : 2; break; | |
51 | case SHORTLINE: lcount=1; break; | |
52 | } | |
53 | if (lcount<=0) return; | |
54 | nodata = cr-cl>=ncol || noheight || allh(i); | |
55 | if (!nodata) | |
56 | fprintf(tabout, "\\v'-.5m'"); | |
57 | for(ln=oldpos=0; ln<lcount; ln++) | |
58 | { | |
59 | linpos = 2*ln - lcount +1; | |
60 | if (linpos != oldpos) | |
61 | fprintf(tabout, "\\v'%dp'", linpos-oldpos); | |
62 | oldpos=linpos; | |
63 | if (shortl==0) | |
64 | { | |
65 | tohcol(cl); | |
66 | if (lcount>1) | |
67 | { | |
68 | switch(interv(i,cl)) | |
69 | { | |
70 | case TOP: exhl = ln==0 ? "1p" : "-1p"; break; | |
71 | case BOT: exhl = ln==1 ? "1p" : "-1p"; break; | |
72 | case THRU: exhl = "1p"; break; | |
73 | } | |
74 | if (exhl[0]) | |
75 | fprintf(tabout, "\\h'%s'", exhl); | |
76 | } | |
77 | else if (lcount==1) | |
78 | { | |
79 | switch(interv(i,cl)) | |
80 | { | |
81 | case TOP: case BOT: exhl = "-1p"; break; | |
82 | case THRU: exhl = "1p"; break; | |
83 | } | |
84 | if (exhl[0]) | |
85 | fprintf(tabout, "\\h'%s'", exhl); | |
86 | } | |
87 | if (lcount>1) | |
88 | { | |
89 | switch(interv(i,cr+1)) | |
90 | { | |
91 | case TOP: exhr = ln==0 ? "-1p" : "+1p"; break; | |
92 | case BOT: exhr = ln==1 ? "-1p" : "+1p"; break; | |
93 | case THRU: exhr = "-1p"; break; | |
94 | } | |
95 | } | |
96 | else if (lcount==1) | |
97 | { | |
98 | switch(interv(i,cr+1)) | |
99 | { | |
100 | case TOP: case BOT: exhr = "+1p"; break; | |
101 | case THRU: exhr = "-1p"; break; | |
102 | } | |
103 | } | |
104 | } | |
105 | else | |
106 | fprintf(tabout, "\\h'|\\n(%du'", cl+CLEFT); | |
107 | fprintf(tabout, "\\s\\n(%d",LSIZE); | |
108 | if (linsize) | |
109 | fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE); | |
110 | if (shortl) | |
111 | fprintf(tabout, "\\l'|\\n(%du'", cr+CRIGHT); | |
112 | else | |
113 | { | |
114 | lnch = "\\(ul"; | |
115 | if (pr1403) | |
116 | lnch = lintype==2 ? "=" : "\\(ru"; | |
117 | if (cr+1>=ncol) | |
118 | fprintf(tabout, "\\l'|\\n(TWu%s%s'", exhr,lnch); | |
119 | else | |
120 | fprintf(tabout, "\\l'(|\\n(%du+|\\n(%du)/2u%s%s'", cr+CRIGHT, | |
121 | cr+1+CLEFT, exhr, lnch); | |
122 | } | |
123 | if (linsize) | |
124 | fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE); | |
125 | fprintf(tabout, "\\s0"); | |
126 | } | |
127 | if (oldpos!=0) | |
128 | fprintf(tabout, "\\v'%dp'", -oldpos); | |
129 | if (!nodata) | |
130 | fprintf(tabout, "\\v'+.5m'"); | |
131 | } | |
132 | getstop() | |
133 | { | |
134 | int i,c,k,junk, stopp; | |
135 | stopp=1; | |
136 | for(i=0; i<MAXLIN; i++) | |
137 | linestop[i]=0; | |
138 | for(i=0; i<nlin; i++) | |
139 | for(c=0; c<ncol; c++) | |
140 | { | |
141 | k = left(i,c,&junk); | |
142 | if (k>=0 && linestop[k]==0) | |
143 | linestop[k]= ++stopp; | |
144 | } | |
145 | if (boxflg || allflg || dboxflg) | |
146 | linestop[0]=1; | |
147 | } | |
148 | left(i,c, lwidp) | |
149 | int *lwidp; | |
150 | { | |
151 | int kind, li, lj; | |
152 | /* returns -1 if no line to left */ | |
153 | /* returns number of line where it starts */ | |
154 | /* stores into lwid the kind of line */ | |
155 | *lwidp=0; | |
156 | kind = lefdata(i,c); | |
157 | if (kind==0) return(-1); | |
158 | if (i+1<nlin) | |
159 | if (lefdata(next(i),c)== kind) return(-1); | |
160 | while (i>=0 && lefdata(i,c)==kind) | |
161 | i=prev(li=i); | |
162 | if (prev(li)== -1) li=0; | |
163 | *lwidp=kind; | |
164 | for(lj= i+1; lj<li; lj++) | |
165 | if (instead[lj] && strcmp(instead[lj], ".TH")==0) | |
166 | return(li); | |
167 | for(i= i+1; i<li; i++) | |
168 | if (fullbot[i]) | |
169 | li=i; | |
170 | return(li); | |
171 | } | |
172 | lefdata(i,c) | |
173 | { | |
174 | int ck; | |
175 | if (i>=nlin) i=nlin-1; | |
176 | if (ctype(i,c) == 's') | |
177 | { | |
178 | for(ck=c; ctype(i,ck)=='s'; ck--); | |
179 | if (thish(i,ck)==0) | |
180 | return(0); | |
181 | } | |
182 | i =stynum[i]; | |
183 | i = lefline[i][c]; | |
184 | if (i>0) return(i); | |
185 | if (dboxflg && c==0) return(2); | |
186 | if (allflg)return(1); | |
187 | if (boxflg && c==0) return(1); | |
188 | return(0); | |
189 | } | |
190 | next(i) | |
191 | { | |
192 | while (i+1 <nlin) | |
193 | { | |
194 | i++; | |
195 | if (!fullbot[i] && !instead[i]) break; | |
196 | } | |
197 | return(i); | |
198 | } | |
199 | prev(i) | |
200 | { | |
201 | while (--i >=0 && (fullbot[i] || instead[i])) | |
202 | ; | |
203 | return(i); | |
204 | } |