2 * Copyright 1990 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
17 /* tu.c: draws horizontal lines */
20 void drawline(int, int, int, int, int, int);
23 makeline(int i
, int c
, int lintype
)
29 shortl
= (table
[i
][c
].col
[0]=='\\');
30 if (c
>0 && !shortl
&& thish(i
,c
-1) == type
)return;
32 for(cr
=c
; cr
< ncol
&& (ctype(i
,cr
)=='s'||type
==thish(i
,cr
)); cr
++);
34 for(cr
=c
+1; cr
<ncol
&& ctype(i
,cr
)=='s'; cr
++);
35 drawline(i
, c
, cr
-1, lintype
, 0, shortl
);
39 fullwide(int i
, int lintype
)
43 fprintf(tabout
, ".nr %d \\n(.v\n.vs \\n(.vu-\\n(.sp\n", SVS
);
48 while (i
>0 && vspand(prev(i
),cl
,1))
50 for(cr
=cl
; cr
<ncol
; cr
++)
51 if (i
>0 && vspand(prev(i
),cr
,1))
54 drawline(i
,cl
,(cr
<ncol
?cr
-1:cr
),lintype
,1,0);
56 fprintf(tabout
, "\n");
58 fprintf(tabout
, ".vs \\n(%du\n", SVS
);
62 drawline(int i
, int cl
, int cr
, int lintype
, int noheight
, int shortl
)
64 char *exhr
, *exhl
, *lnch
;
65 int lcount
, ln
, linpos
, oldpos
, nodata
;
70 case '-': lcount
=1;break;
71 case '=': lcount
= pr1403
? 1 : 2; break;
72 case SHORTLINE
: lcount
=1; break;
74 if (lcount
<=0) return;
75 nodata
= cr
-cl
>=ncol
|| noheight
|| allh(i
);
77 fprintf(tabout
, "\\v'-.5m'");
78 for(ln
=oldpos
=0; ln
<lcount
; ln
++)
80 linpos
= 2*ln
- lcount
+1;
82 fprintf(tabout
, "\\v'%dp'", linpos
-oldpos
);
91 case TOP
: exhl
= ln
==0 ? "1p" : "-1p"; break;
92 case BOT
: exhl
= ln
==1 ? "1p" : "-1p"; break;
93 case THRU
: exhl
= "1p"; break;
96 fprintf(tabout
, "\\h'%s'", exhl
);
102 case TOP
: case BOT
: exhl
= "-1p"; break;
103 case THRU
: exhl
= "1p"; break;
106 fprintf(tabout
, "\\h'%s'", exhl
);
110 switch(interv(i
,cr
+1))
112 case TOP
: exhr
= ln
==0 ? "-1p" : "+1p"; break;
113 case BOT
: exhr
= ln
==1 ? "-1p" : "+1p"; break;
114 case THRU
: exhr
= "-1p"; break;
119 switch(interv(i
,cr
+1))
121 case TOP
: case BOT
: exhr
= "+1p"; break;
122 case THRU
: exhr
= "-1p"; break;
127 fprintf(tabout
, "\\h'|\\n(%du'", cl
+CLEFT
);
128 fprintf(tabout
, "\\s\\n(%d",LSIZE
);
130 fprintf(tabout
, "\\v'-\\n(%dp/6u'", LSIZE
);
132 fprintf(tabout
, "\\l'|\\n(%du'", cr
+CRIGHT
);
137 lnch
= lintype
==2 ? "=" : "\\(ru";
139 fprintf(tabout
, "\\l'|\\n(TWu%s%s'", exhr
,lnch
);
141 fprintf(tabout
, "\\l'(|\\n(%du+|\\n(%du)/2u%s%s'", cr
+CRIGHT
,
142 cr
+1+CLEFT
, exhr
, lnch
);
145 fprintf(tabout
, "\\v'\\n(%dp/6u'", LSIZE
);
146 fprintf(tabout
, "\\s0");
149 fprintf(tabout
, "\\v'%dp'", -oldpos
);
151 fprintf(tabout
, "\\v'+.5m'");
157 int i
,c
,k
,junk
, stopp
;
159 for(i
=0; i
<MAXLIN
; i
++)
161 for(i
=0; i
<nlin
; i
++)
162 for(c
=0; c
<ncol
; c
++)
165 if (k
>=0 && linestop
[k
]==0)
166 linestop
[k
]= ++stopp
;
168 if (boxflg
|| allflg
|| dboxflg
)
173 left(int i
, int c
, int *lwidp
)
176 /* returns -1 if no line to left */
177 /* returns number of line where it starts */
178 /* stores into lwid the kind of line */
181 if (kind
==0) return(-1);
183 if (lefdata(next(i
),c
)== kind
) return(-1);
184 while (i
>=0 && lefdata(i
,c
)==kind
)
186 if (prev(li
)== -1) li
=0;
188 for(lj
= i
+1; lj
<li
; lj
++)
189 if (instead
[lj
] && strcmp(instead
[lj
], ".TH")==0)
191 for(i
= i
+1; i
<li
; i
++)
198 lefdata(int i
, int c
)
201 if (i
>=nlin
) i
=nlin
-1;
202 if (ctype(i
,c
) == 's')
204 for(ck
=c
; ctype(i
,ck
)=='s'; ck
--);
211 if (dboxflg
&& c
==0) return(2);
212 if (allflg
)return(1);
213 if (boxflg
&& c
==0) return(1);
223 if (!fullbot
[i
] && !instead
[i
]) break;
231 while (--i
>=0 && (fullbot
[i
] || instead
[i
]))