Commit | Line | Data |
---|---|---|
6869a338 | 1 | #ifndef lint |
5e785082 | 2 | static char *sccsid = "@(#)tth19.c 3.8 83/08/17"; |
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 | ||
20 | char h19_frame[16] = { | |
21 | ' ', '`'|0x80, 'a'|0x80, 'e'|0x80, | |
22 | '`'|0x80, '`'|0x80, 'f'|0x80, 'v'|0x80, | |
23 | 'a'|0x80, 'd'|0x80, 'a'|0x80, 'u'|0x80, | |
24 | 'c'|0x80, 't'|0x80, 's'|0x80, 'b'|0x80 | |
25 | }; | |
26 | ||
27 | char h19_row, h19_col; | |
28 | char h19_modes, h19_nmodes; | |
29 | char h19_insert, h19_ninsert; | |
30 | char h19_graphics; | |
31 | short h19_msp10c; | |
c3f80cb5 EW |
32 | char *h19_VS; |
33 | char *h19_VE; | |
6869a338 EW |
34 | |
35 | #define pc(c) putchar('c') | |
36 | #define esc() pc(\033) | |
37 | #define PAD(ms10) { \ | |
38 | register i; \ | |
39 | for (i = ((ms10) + 5) / h19_msp10c; --i >= 0;) \ | |
40 | pc(\0); \ | |
41 | } | |
42 | #define ICPAD() PAD((80 - h19_col) * 1) /* 0.1 ms per char */ | |
43 | #define ILPAD() PAD((24 - h19_row) * 10); /* 1 ms per char */ | |
44 | ||
45 | #define SETINSERT(m) \ | |
46 | ((m) != h19_insert \ | |
47 | ? (esc(), (h19_insert = (m)) ? pc(@) : pc(O)) : 0) | |
48 | #define SETMODES(m) \ | |
49 | ((m) != h19_modes \ | |
50 | ? (esc(), (h19_modes = (m)) ? pc(p) : pc(q)) : 0) | |
51 | #define SETGRAPHICS(m) \ | |
52 | ((m) != h19_graphics \ | |
53 | ? (esc(), (h19_graphics = (m)) ? pc(F) : pc(G)) : 0) | |
54 | ||
55 | h19_setinsert(new) | |
56 | char new; | |
57 | { | |
58 | h19_ninsert = new; | |
59 | } | |
60 | ||
61 | h19_setmodes(new) | |
62 | { | |
63 | h19_nmodes = new & WWM_REV; | |
64 | } | |
65 | ||
66 | h19_insline() | |
67 | { | |
68 | esc(); | |
69 | pc(L); | |
70 | ILPAD(); | |
71 | } | |
72 | ||
73 | h19_delline() | |
74 | { | |
75 | esc(); | |
76 | pc(M); | |
77 | ILPAD(); | |
78 | } | |
79 | ||
80 | h19_putc(c) | |
81 | register char c; | |
82 | { | |
83 | SETMODES(h19_nmodes); | |
84 | SETINSERT(h19_ninsert); | |
85 | if (c & 0x80) { | |
86 | SETGRAPHICS(1); | |
87 | putchar(c & 0x7f); | |
88 | } else { | |
89 | SETGRAPHICS(0); | |
90 | putchar(c); | |
91 | } | |
92 | if (h19_insert) | |
93 | ICPAD(); | |
5e785082 | 94 | if (++h19_col == 80) |
9574abf2 | 95 | h19_col = 79; |
6869a338 EW |
96 | } |
97 | ||
98 | h19_write(start, end) | |
99 | register char *start, *end; | |
100 | { | |
101 | register char c; | |
102 | ||
103 | SETMODES(h19_nmodes); | |
104 | SETINSERT(h19_ninsert); | |
105 | if (h19_insert) { | |
106 | while (start <= end) { | |
107 | if ((c = *start++) & 0x80) { | |
108 | SETGRAPHICS(1); | |
109 | putchar(c & 0x7f); | |
110 | } else { | |
111 | SETGRAPHICS(0); | |
112 | putchar(c); | |
113 | } | |
114 | ICPAD(); | |
115 | h19_col++; | |
116 | } | |
117 | } else { | |
118 | h19_col += end - start + 1; | |
119 | while (start <= end) | |
120 | if ((c = *start++) & 0x80) { | |
121 | SETGRAPHICS(1); | |
122 | putchar(c & 0x7f); | |
123 | } else { | |
124 | SETGRAPHICS(0); | |
125 | putchar(c); | |
126 | } | |
127 | } | |
5e785082 | 128 | if (h19_col == 80) |
9574abf2 | 129 | h19_col = 79; |
6869a338 EW |
130 | } |
131 | ||
132 | h19_blank(n) | |
133 | register n; | |
134 | { | |
135 | if (n <= 0) | |
136 | return; | |
137 | SETMODES(h19_nmodes); | |
138 | SETINSERT(h19_ninsert); | |
139 | if (h19_insert) { | |
140 | while (--n >= 0) { | |
141 | putchar(' '); | |
142 | ICPAD(); | |
143 | h19_col++; | |
144 | } | |
145 | } else { | |
146 | h19_col += n; | |
147 | while (--n >= 0) | |
148 | putchar(' '); | |
149 | } | |
5e785082 | 150 | if (h19_col == 80) |
9574abf2 | 151 | h19_col = 79; |
6869a338 EW |
152 | } |
153 | ||
154 | h19_move(row, col) | |
155 | register char row, col; | |
156 | { | |
157 | if (h19_row == row) { | |
158 | if (h19_col == col) | |
159 | return; | |
160 | if (h19_col == col - 1) { | |
161 | esc(); | |
162 | pc(C); | |
163 | goto out; | |
164 | } else if (h19_col == col + 1) { | |
165 | pc(\b); | |
166 | goto out; | |
167 | } | |
168 | } | |
169 | if (h19_col == col) { | |
170 | if (h19_row == row + 1) { | |
171 | esc(); | |
172 | pc(A); | |
173 | goto out; | |
174 | } else if (h19_row == row + 1) { | |
175 | pc(\n); | |
176 | goto out; | |
177 | } | |
178 | } | |
7aefc9fe | 179 | if (col == 0 && row == 0) { |
6869a338 EW |
180 | esc(); |
181 | pc(H); | |
182 | goto out; | |
183 | } | |
184 | esc(); | |
185 | pc(Y); | |
186 | putchar(' ' + row); | |
187 | putchar(' ' + col); | |
188 | out: | |
189 | h19_col = col; | |
190 | h19_row = row; | |
191 | } | |
192 | ||
193 | h19_init() | |
6869a338 | 194 | { |
c3f80cb5 EW |
195 | if (h19_VS) |
196 | fputs(h19_VS, stdout); | |
6869a338 | 197 | esc(); |
c3f80cb5 | 198 | pc(w); |
6869a338 EW |
199 | esc(); |
200 | pc(E); | |
6869a338 EW |
201 | h19_col = h19_row = 0; |
202 | h19_insert = 0; | |
203 | h19_graphics = 0; | |
204 | h19_modes = 0; | |
205 | } | |
206 | ||
e908bfac | 207 | h19_end() |
6869a338 EW |
208 | { |
209 | SETMODES(0); | |
210 | SETINSERT(0); | |
211 | SETGRAPHICS(0); | |
c3f80cb5 EW |
212 | if (h19_VE) |
213 | fputs(h19_VE, stdout); | |
6869a338 EW |
214 | esc(); |
215 | pc(v); | |
216 | } | |
217 | ||
218 | h19_clreol() | |
219 | { | |
220 | esc(); | |
221 | pc(K); | |
222 | } | |
223 | ||
224 | h19_clreos() | |
225 | { | |
226 | esc(); | |
227 | pc(J); | |
228 | } | |
229 | ||
230 | h19_clear() | |
231 | { | |
232 | esc(); | |
233 | pc(E); | |
234 | } | |
235 | ||
236 | h19_delchar() | |
237 | { | |
238 | esc(); | |
239 | pc(N); | |
240 | } | |
241 | ||
242 | tt_h19() | |
243 | { | |
e908bfac EW |
244 | float cpms = (float) wwbaud / 10000; /* char per ms */ |
245 | ||
246 | h19_msp10c = 10 / cpms; /* ms per 10 char */ | |
c3f80cb5 EW |
247 | h19_VS = tt_xgetstr("vs"); |
248 | h19_VE = tt_xgetstr("ve"); | |
6869a338 EW |
249 | tt.tt_setinsert = h19_setinsert; |
250 | tt.tt_setmodes = h19_setmodes; | |
251 | tt.tt_insline = h19_insline; | |
252 | tt.tt_delline = h19_delline; | |
253 | tt.tt_delchar = h19_delchar; | |
254 | tt.tt_blank = h19_blank; | |
255 | tt.tt_init = h19_init; | |
e908bfac | 256 | tt.tt_end = h19_end; |
6869a338 EW |
257 | tt.tt_clreol = h19_clreol; |
258 | tt.tt_clreos = h19_clreos; | |
259 | tt.tt_clear = h19_clear; | |
260 | tt.tt_move = h19_move; | |
6869a338 EW |
261 | tt.tt_write = h19_write; |
262 | tt.tt_putc = h19_putc; | |
263 | tt.tt_ncol = 80; | |
264 | tt.tt_nrow = 24; | |
6fc023ad | 265 | tt.tt_availmodes = WWM_REV; |
6869a338 EW |
266 | tt.tt_frame = h19_frame; |
267 | return 0; | |
268 | } |