tt.c revision b55148877d473978f0b46d593fd6213fa526fcc5
1/*
2 * Copyright 1990 Sun Microsystems, Inc.  All rights reserved.
3 * Use is subject to license terms.
4 */
5
6/*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
7/*	  All Rights Reserved  	*/
8
9/*
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.
13 */
14
15#pragma ident	"%Z%%M%	%I%	%E% SMI"
16
17 /* tt.c: subroutines for drawing horizontal lines */
18# include "t..c"
19
20int
21ctype(int il, int ic)
22{
23if (instead[il])
24	return(0);
25if (fullbot[il])
26	return(0);
27il = stynum[il];
28return(style[il][ic]);
29}
30
31int
32min(int a, int b)
33{
34return(a<b ? a : b);
35}
36
37int
38fspan(int i, int c)
39{
40c++;
41return(c<ncol && ctype(i,c)=='s');
42}
43
44int
45lspan(int i, int c)
46{
47int k;
48if (ctype(i,c) != 's') return(0);
49c++;
50if (c < ncol && ctype(i,c)== 's')
51	return(0);
52for(k=0; ctype(i,--c) == 's'; k++);
53return(k);
54}
55
56int
57ctspan(int i, int c)
58{
59int k;
60c++;
61for(k=1; c<ncol && ctype(i,c)=='s'; k++)
62	c++;
63return(k);
64}
65
66void
67tohcol(int ic)
68{
69			if (ic==0)
70				fprintf(tabout, "\\h'|0'");
71			else
72				fprintf(tabout, "\\h'(|\\n(%du+|\\n(%du)/2u'", ic+CLEFT, ic+CRIGHT-1);
73}
74
75int
76allh(int i)
77{
78/* return true if every element in line i is horizontal */
79/* also at least one must be horizontl */
80int c, one, k;
81if (fullbot[i]) return(1);
82for(one=c=0; c<ncol; c++)
83	{
84	k = thish(i,c);
85	if (k==0) return(0);
86	if (k==1) continue;
87	one=1;
88	}
89return(one);
90}
91
92int
93thish(int i, int c)
94{
95	int t;
96	char *s;
97	struct colstr *pc;
98	if (c<0)return(0);
99	if (i<0) return(0);
100	t = ctype(i,c);
101	if (t=='_' || t == '-')
102		return('-');
103	if (t=='=')return('=');
104	if (t=='^') return(1);
105	if (fullbot[i] )
106		return(fullbot[i]);
107	if (t=='s') return(thish(i,c-1));
108	if (t==0) return(1);
109	pc = &table[i][c];
110	s = (t=='a' ? pc->rcol : pc->col);
111	if (s==0 || (point(s) && *s==0))
112		return(1);
113	if (vspen(s)) return(1);
114	if (t=barent( s))
115		return(t);
116	return(0);
117}
118