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 /* tv.c: draw vertical lines */ 16 # include "t..c" 17 18 void 19 drawvert(int start, int end, int c, int lwid) 20 { 21 char *exb=0, *ext=0; 22 int tp=0, sl, ln, pos, epb, ept, vm; 23 end++; 24 vm='v'; 25 /* note: nr 35 has value of 1m outside of linesize */ 26 while (instead[end]) end++; 27 for(ln=0; ln<lwid; ln++) 28 { 29 epb=ept=0; 30 pos = 2*ln-lwid+1; 31 if (pos!=tp) fprintf(tabout, "\\h'%dp'", pos-tp); 32 tp = pos; 33 if (end<nlin) 34 { 35 if (fullbot[end]|| (!instead[end] && allh(end))) 36 epb=2; 37 else 38 switch (midbar(end,c)) 39 { 40 case '-': 41 exb = "1v-.5m"; break; 42 case '=': 43 exb = "1v-.5m"; 44 epb = 1; break; 45 } 46 } 47 if (lwid>1) 48 switch(interh(end, c)) 49 { 50 case THRU: epb -= 1; break; 51 case RIGHT: epb += (ln==0 ? 1 : -1); break; 52 case LEFT: epb += (ln==1 ? 1 : -1); break; 53 } 54 if (lwid==1) 55 switch(interh(end,c)) 56 { 57 case THRU: epb -= 1; break; 58 case RIGHT: case LEFT: epb += 1; break; 59 } 60 if (start>0) 61 { 62 sl = start-1; 63 while (sl>=0 && instead[sl]) sl--; 64 if (sl>=0 && (fullbot[sl] || allh(sl))) 65 ept=0; 66 else 67 if (sl>=0) 68 switch(midbar(sl,c)) 69 { 70 case '-': 71 ext = ".5m"; break; 72 case '=': 73 ext= ".5m"; ept = -1; break; 74 default: 75 vm = 'm'; break; 76 } 77 else 78 ept = -4; 79 } 80 else if (start==0 && allh(0)) 81 { 82 ept=0; 83 vm = 'm'; 84 } 85 if (lwid>1) 86 switch(interh(start,c)) 87 { 88 case THRU: ept += 1; break; 89 case LEFT: ept += (ln==0 ? 1 : -1); break; 90 case RIGHT: ept += (ln==1 ? 1 : -1); break; 91 } 92 else if (lwid==1) 93 switch(interh(start,c)) 94 { 95 case THRU: ept += 1; break; 96 case LEFT: case RIGHT: ept -= 1; break; 97 } 98 if (exb) 99 fprintf(tabout, "\\v'%s'", exb); 100 if (epb) 101 fprintf(tabout, "\\v'%dp'", epb); 102 fprintf(tabout, "\\s\\n(%d",LSIZE); 103 if (linsize) 104 fprintf(tabout, "\\v'-\\n(%dp/6u'", LSIZE); 105 fprintf(tabout, "\\h'-\\n(#~u'"); /* adjustment for T450 nroff boxes */ 106 fprintf(tabout, "\\L'|\\n(#%cu-%s", linestop[start]+'a'-1, vm=='v'? "1v" : "\\n(35u"); 107 if (ext) 108 fprintf(tabout, "-(%s)",ext); 109 if (exb) 110 fprintf(tabout, "-(%s)", exb); 111 pos = ept-epb; 112 if (pos) 113 fprintf(tabout, "%s%dp", pos>=0? "+" : "", pos); 114 /* the string #d is either "nl" or ".d" depending 115 on diversions; on GCOS not the same */ 116 fprintf(tabout, "'\\s0\\v'\\n(\\*(#du-\\n(#%cu+%s", linestop[start]+'a'-1,vm=='v' ? "1v" : "\\n(35u"); 117 if (ext) 118 fprintf(tabout, "+%s",ext); 119 if (ept) 120 fprintf(tabout, "%s%dp", (-ept)>0 ? "+" : "", (-ept)); 121 fprintf(tabout, "'"); 122 if (linsize) 123 fprintf(tabout, "\\v'\\n(%dp/6u'", LSIZE); 124 } 125 } 126 127 int 128 midbar(int i, int c) 129 { 130 int k; 131 k = midbcol(i,c); 132 if (k==0 && c>0) 133 k = midbcol(i, c-1); 134 return(k); 135 } 136 137 int 138 midbcol(int i, int c) 139 { 140 int ct; 141 while ( (ct=ctype(i,c)) == 's') 142 c--; 143 if (ct=='-' || ct == '=') 144 return(ct); 145 if (ct=barent(table[i][c].col)) 146 return(ct); 147 return(0); 148 } 149 150 int 151 barent(char *s) 152 { 153 if (s==0) return (1); 154 if (!point(s)) return(1); 155 if (s[0]== '\\') s++; 156 if (s[1]!= 0) 157 return(0); 158 switch(s[0]) 159 { 160 case '_': 161 return('-'); 162 case '=': 163 return('='); 164 } 165 return(0); 166 } 167