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