1 /* 2 * Copyright (c) 1983 Regents of the University of California. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms are permitted 6 * provided that the above copyright notice and this paragraph are 7 * duplicated in all such forms and that any documentation, 8 * advertising materials, and other materials related to such 9 * distribution and use acknowledge that the software was developed 10 * by the University of California, Berkeley. The name of the 11 * University may not be used to endorse or promote products derived 12 * from this software without specific prior written permission. 13 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR 14 * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED 15 * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16 */ 17 18 #ifndef lint 19 static char sccsid[] = "@(#)tth19.c 3.20 (Berkeley) 05/11/89"; 20 #endif /* not lint */ 21 22 #include "ww.h" 23 #include "tt.h" 24 25 /* 26 kb|h19|heath|h19-b|h19b|heathkit|heath-19|z19|zenith: 27 cr=^M:nl=^J:bl=^G:al=1*\EL:am:le=^H:bs:cd=\EJ:ce=\EK: 28 cl=\EE:cm=\EY%+ %+ :co#80:dc=\EN:dl=1*\EM:do=\EB: 29 ei=\EO:ho=\EH:im=\E@:li#24:mi:nd=\EC:as=\EF:ae=\EG:ms: 30 ta=^I:pt:sr=\EI:se=\Eq:so=\Ep:up=\EA:vs=\Ex4:ve=\Ey4: 31 kb=^h:ku=\EA:kd=\EB:kl=\ED:kr=\EC:kh=\EH: 32 kn#8:k1=\ES:k2=\ET:k3=\EU:k4=\EV:k5=\EW: 33 l6=blue:l7=red:l8=white:k6=\EP:k7=\EQ:k8=\ER: 34 es:hs:ts=\Ej\Ex5\Ex1\EY8%+ \Eo:fs=\Ek\Ey5:ds=\Ey1: 35 */ 36 37 #define NCOL 80 38 #define NROW 24 39 40 #define G (WWM_GRP << WWC_MSHIFT) 41 short h19_frame[16] = { 42 ' ', '`'|G, 'a'|G, 'e'|G, 43 '`'|G, '`'|G, 'f'|G, 'v'|G, 44 'a'|G, 'd'|G, 'a'|G, 'u'|G, 45 'c'|G, 't'|G, 's'|G, 'b'|G 46 }; 47 48 extern struct tt_str *gen_VS; 49 extern struct tt_str *gen_VE; 50 51 int h19_msp10c; 52 53 #define pc(c) ttputc(c) 54 #define esc() pc('\033') 55 #define PAD(ms10) { \ 56 register i; \ 57 for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \ 58 pc('\0'); \ 59 } 60 #define ICPAD() PAD((NCOL - tt.tt_col) * 1) /* 0.1 ms per char */ 61 #define ILPAD() PAD((NROW - tt.tt_row) * 10) /* 1 ms per char */ 62 63 #define H19_SETINSERT(m) (esc(), (tt.tt_insert = (m)) ? pc('@') : pc('O')) 64 65 h19_setinsert(new) 66 { 67 H19_SETINSERT(new); 68 } 69 70 h19_setmodes(new) 71 register new; 72 { 73 register diff; 74 75 diff = new ^ tt.tt_modes; 76 if (diff & WWM_REV) { 77 esc(); 78 if (new & WWM_REV) 79 pc('p'); 80 else 81 pc('q'); 82 } 83 if (diff & WWM_GRP) { 84 esc(); 85 if (new & WWM_GRP) 86 pc('F'); 87 else 88 pc('G'); 89 } 90 tt.tt_modes = new; 91 } 92 93 h19_insline(n) 94 { 95 while (--n >= 0) { 96 esc(); 97 pc('L'); 98 ILPAD(); 99 } 100 } 101 102 h19_delline(n) 103 { 104 while (--n >= 0) { 105 esc(); 106 pc('M'); 107 ILPAD(); 108 } 109 } 110 111 h19_putc(c) 112 register char c; 113 { 114 if (tt.tt_nmodes != tt.tt_modes) 115 (*tt.tt_setmodes)(tt.tt_nmodes); 116 if (tt.tt_ninsert != tt.tt_insert) 117 H19_SETINSERT(tt.tt_ninsert); 118 pc(c); 119 if (tt.tt_insert) 120 ICPAD(); 121 if (++tt.tt_col == NCOL) 122 tt.tt_col = NCOL - 1; 123 } 124 125 h19_write(p, n) 126 register char *p; 127 register n; 128 { 129 if (tt.tt_nmodes != tt.tt_modes) 130 (*tt.tt_setmodes)(tt.tt_nmodes); 131 if (tt.tt_ninsert != tt.tt_insert) 132 H19_SETINSERT(tt.tt_ninsert); 133 if (tt.tt_insert) { 134 while (--n >= 0) { 135 pc(*p++); 136 ICPAD(); 137 tt.tt_col++; 138 } 139 } else { 140 tt.tt_col += n; 141 ttwrite(p, n); 142 } 143 if (tt.tt_col == NCOL) 144 tt.tt_col = NCOL - 1; 145 } 146 147 h19_move(row, col) 148 register char row, col; 149 { 150 if (tt.tt_row == row) { 151 if (tt.tt_col == col) 152 return; 153 if (col == 0) { 154 pc('\r'); 155 goto out; 156 } 157 if (tt.tt_col == col - 1) { 158 esc(); 159 pc('C'); 160 goto out; 161 } 162 if (tt.tt_col == col + 1) { 163 pc('\b'); 164 goto out; 165 } 166 } 167 if (tt.tt_col == col) { 168 if (tt.tt_row == row + 1) { 169 esc(); 170 pc('A'); 171 goto out; 172 } 173 if (tt.tt_row == row - 1) { 174 pc('\n'); 175 goto out; 176 } 177 } 178 if (col == 0 && row == 0) { 179 esc(); 180 pc('H'); 181 goto out; 182 } 183 esc(); 184 pc('Y'); 185 pc(' ' + row); 186 pc(' ' + col); 187 out: 188 tt.tt_col = col; 189 tt.tt_row = row; 190 } 191 192 h19_init() 193 { 194 if (gen_VS) 195 ttxputs(gen_VS); 196 esc(); 197 pc('w'); 198 esc(); 199 pc('E'); 200 tt.tt_col = tt.tt_row = 0; 201 tt.tt_ninsert = tt.tt_insert = 0; 202 tt.tt_nmodes = tt.tt_modes = 0; 203 } 204 205 h19_end() 206 { 207 if (gen_VE) 208 ttxputs(gen_VE); 209 esc(); 210 pc('v'); 211 } 212 213 h19_clreol() 214 { 215 esc(); 216 pc('K'); 217 } 218 219 h19_clreos() 220 { 221 esc(); 222 pc('J'); 223 } 224 225 h19_clear() 226 { 227 esc(); 228 pc('E'); 229 } 230 231 h19_delchar(n) 232 { 233 while (--n >= 0) { 234 esc(); 235 pc('N'); 236 } 237 } 238 239 h19_scroll_down(n) 240 { 241 h19_move(NROW - 1, 0); 242 while (--n >= 0) 243 pc('\n'); 244 } 245 246 h19_scroll_up(n) 247 { 248 h19_move(0, 0); 249 while (--n >= 0) { 250 esc(); 251 pc('I'); 252 } 253 } 254 255 tt_h19() 256 { 257 float cpms = (float) wwbaud / 10000; /* char per ms */ 258 259 h19_msp10c = 10 / cpms; /* ms per 10 char */ 260 gen_VS = ttxgetstr("vs"); 261 gen_VE = ttxgetstr("ve"); 262 263 tt.tt_init = h19_init; 264 tt.tt_end = h19_end; 265 266 tt.tt_insline = h19_insline; 267 tt.tt_delline = h19_delline; 268 tt.tt_delchar = h19_delchar; 269 tt.tt_clreol = h19_clreol; 270 tt.tt_clreos = h19_clreos; 271 tt.tt_clear = h19_clear; 272 tt.tt_move = h19_move; 273 tt.tt_write = h19_write; 274 tt.tt_putc = h19_putc; 275 tt.tt_scroll_down = h19_scroll_down; 276 tt.tt_scroll_up = h19_scroll_up; 277 tt.tt_setinsert = h19_setinsert; 278 tt.tt_setmodes = h19_setmodes; 279 280 tt.tt_ncol = NCOL; 281 tt.tt_nrow = NROW; 282 tt.tt_availmodes = WWM_REV|WWM_GRP; 283 tt.tt_frame = h19_frame; 284 return 0; 285 } 286