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