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