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