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