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