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