Research V7 development
[unix-history] / usr / src / cmd / tbl / tt.c
CommitLineData
67305323
ML
1 /* tt.c: subroutines for drawing horizontal lines */
2# include "t..c"
3ctype(il, ic)
4{
5if (instead[il])
6 return(0);
7if (fullbot[il])
8 return(0);
9il = stynum[il];
10return(style[il][ic]);
11}
12min(a,b)
13{
14return(a<b ? a : b);
15}
16fspan(i,c)
17{
18c++;
19return(c<ncol && ctype(i,c)=='s');
20}
21lspan(i,c)
22{
23int k;
24if (ctype(i,c) != 's') return(0);
25c++;
26if (c < ncol && ctype(i,c)== 's')
27 return(0);
28for(k=0; ctype(i,--c) == 's'; k++);
29return(k);
30}
31ctspan(i,c)
32{
33int k;
34c++;
35for(k=1; c<ncol && ctype(i,c)=='s'; k++)
36 c++;
37return(k);
38}
39tohcol(ic)
40{
41 if (ic==0)
42 fprintf(tabout, "\\h'|0'");
43 else
44 fprintf(tabout, "\\h'(|\\n(%du+|\\n(%du)/2u'", ic+CLEFT, ic+CRIGHT-1);
45}
46allh(i)
47{
48/* return true if every element in line i is horizontal */
49/* also at least one must be horizontl */
50int c, one, k;
51if (fullbot[i]) return(1);
52for(one=c=0; c<ncol; c++)
53 {
54 k = thish(i,c);
55 if (k==0) return(0);
56 if (k==1) continue;
57 one=1;
58 }
59return(one);
60}
61thish(i,c)
62{
63 int t;
64 char *s;
65 struct colstr *pc;
66 if (c<0)return(0);
67 if (i<0) return(0);
68 t = ctype(i,c);
69 if (t=='_' || t == '-')
70 return('-');
71 if (t=='=')return('=');
72 if (t=='^') return(1);
73 if (fullbot[i] )
74 return(fullbot[i]);
75 if (t=='s') return(thish(i,c-1));
76 if (t==0) return(1);
77 pc = &table[i][c];
78 s = (t=='a' ? pc->rcol : pc->col);
79 if (s==0 || (point(s) && *s==0))
80 return(1);
81 if (vspen(s)) return(1);
82 if (t=barent( s))
83 return(t);
84 return(0);
85}