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