wsemul_vt100.c revision 1.4 1 1.4 drochner /* $NetBSD: wsemul_vt100.c,v 1.4 1998/06/26 22:35:27 drochner Exp $ */
2 1.1 drochner
3 1.1 drochner /*
4 1.1 drochner * Copyright (c) 1998
5 1.1 drochner * Matthias Drochner. All rights reserved.
6 1.1 drochner *
7 1.1 drochner * Redistribution and use in source and binary forms, with or without
8 1.1 drochner * modification, are permitted provided that the following conditions
9 1.1 drochner * are met:
10 1.1 drochner * 1. Redistributions of source code must retain the above copyright
11 1.1 drochner * notice, this list of conditions and the following disclaimer.
12 1.1 drochner * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 drochner * notice, this list of conditions and the following disclaimer in the
14 1.1 drochner * documentation and/or other materials provided with the distribution.
15 1.1 drochner * 3. All advertising materials mentioning features or use of this software
16 1.1 drochner * must display the following acknowledgement:
17 1.1 drochner * This product includes software developed for the NetBSD Project
18 1.1 drochner * by Matthias Drochner.
19 1.1 drochner * 4. The name of the author may not be used to endorse or promote products
20 1.1 drochner * derived from this software without specific prior written permission.
21 1.1 drochner *
22 1.1 drochner * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23 1.1 drochner * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24 1.1 drochner * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25 1.1 drochner * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26 1.1 drochner * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27 1.1 drochner * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 1.1 drochner * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 1.1 drochner * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 1.1 drochner * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31 1.1 drochner * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 1.1 drochner *
33 1.1 drochner */
34 1.1 drochner
35 1.1 drochner #include <sys/param.h>
36 1.1 drochner #include <sys/systm.h>
37 1.1 drochner #include <sys/time.h>
38 1.1 drochner #include <sys/malloc.h>
39 1.1 drochner #include <sys/fcntl.h>
40 1.1 drochner
41 1.1 drochner #include <dev/wscons/wsconsio.h>
42 1.1 drochner #include <dev/wscons/wsdisplayvar.h>
43 1.1 drochner #include <dev/wscons/wsemulvar.h>
44 1.1 drochner #include <dev/wscons/wsemul_vt100var.h>
45 1.1 drochner #include <dev/wscons/ascii.h>
46 1.1 drochner
47 1.1 drochner #include "opt_wskernattr.h"
48 1.1 drochner
49 1.1 drochner void *wsemul_vt100_cnattach __P((const struct wsscreen_descr *, void *,
50 1.1 drochner int, int, long));
51 1.1 drochner void *wsemul_vt100_attach __P((int console, const struct wsscreen_descr *,
52 1.1 drochner void *, int, int, void *, long));
53 1.1 drochner void wsemul_vt100_output __P((void *cookie, const u_char *data, u_int count,
54 1.1 drochner int));
55 1.1 drochner void wsemul_vt100_detach __P((void *cookie, u_int *crowp, u_int *ccolp));
56 1.1 drochner
57 1.1 drochner const struct wsemul_ops wsemul_vt100_ops = {
58 1.1 drochner "vt100",
59 1.1 drochner wsemul_vt100_cnattach,
60 1.1 drochner wsemul_vt100_attach,
61 1.1 drochner wsemul_vt100_output,
62 1.1 drochner wsemul_vt100_translate,
63 1.1 drochner wsemul_vt100_detach,
64 1.1 drochner };
65 1.1 drochner
66 1.1 drochner struct wsemul_vt100_emuldata wsemul_vt100_console_emuldata;
67 1.1 drochner
68 1.1 drochner static void wsemul_vt100_init __P((struct wsemul_vt100_emuldata *,
69 1.1 drochner const struct wsscreen_descr *,
70 1.1 drochner void *, int, int, long));
71 1.1 drochner
72 1.1 drochner static u_int wsemul_vt100_output_normal __P((struct wsemul_vt100_emuldata *,
73 1.1 drochner u_char, int));
74 1.1 drochner typedef u_int vt100_handler __P((struct wsemul_vt100_emuldata *, u_char));
75 1.1 drochner static vt100_handler
76 1.1 drochner wsemul_vt100_output_esc,
77 1.1 drochner wsemul_vt100_output_csi,
78 1.1 drochner wsemul_vt100_output_scs94,
79 1.1 drochner wsemul_vt100_output_scs94_percent,
80 1.1 drochner wsemul_vt100_output_scs96,
81 1.1 drochner wsemul_vt100_output_scs96_percent,
82 1.3 drochner wsemul_vt100_output_esc_hash,
83 1.1 drochner wsemul_vt100_output_esc_spc,
84 1.1 drochner wsemul_vt100_output_string,
85 1.1 drochner wsemul_vt100_output_string_esc,
86 1.1 drochner wsemul_vt100_output_dcs,
87 1.1 drochner wsemul_vt100_output_dcs_dollar;
88 1.1 drochner
89 1.1 drochner #define VT100_EMUL_STATE_NORMAL 0 /* normal processing */
90 1.1 drochner #define VT100_EMUL_STATE_ESC 1 /* got ESC */
91 1.1 drochner #define VT100_EMUL_STATE_CSI 2 /* got CSI (ESC[) */
92 1.3 drochner #define VT100_EMUL_STATE_SCS94 3 /* got ESC{()*+} */
93 1.3 drochner #define VT100_EMUL_STATE_SCS94_PERCENT 4 /* got ESC{()*+}% */
94 1.3 drochner #define VT100_EMUL_STATE_SCS96 5 /* got ESC{-./} */
95 1.3 drochner #define VT100_EMUL_STATE_SCS96_PERCENT 6 /* got ESC{-./}% */
96 1.3 drochner #define VT100_EMUL_STATE_ESC_HASH 7 /* got ESC# */
97 1.3 drochner #define VT100_EMUL_STATE_ESC_SPC 8 /* got ESC<SPC> */
98 1.3 drochner #define VT100_EMUL_STATE_STRING 9 /* waiting for ST (ESC\) */
99 1.3 drochner #define VT100_EMUL_STATE_STRING_ESC 10 /* waiting for ST, got ESC */
100 1.3 drochner #define VT100_EMUL_STATE_DCS 11 /* got DCS (ESC P) */
101 1.3 drochner #define VT100_EMUL_STATE_DCS_DOLLAR 12 /* got DCS<p>$ */
102 1.1 drochner
103 1.1 drochner vt100_handler *vt100_output[] = {
104 1.1 drochner wsemul_vt100_output_esc,
105 1.1 drochner wsemul_vt100_output_csi,
106 1.1 drochner wsemul_vt100_output_scs94,
107 1.1 drochner wsemul_vt100_output_scs94_percent,
108 1.1 drochner wsemul_vt100_output_scs96,
109 1.1 drochner wsemul_vt100_output_scs96_percent,
110 1.3 drochner wsemul_vt100_output_esc_hash,
111 1.1 drochner wsemul_vt100_output_esc_spc,
112 1.1 drochner wsemul_vt100_output_string,
113 1.1 drochner wsemul_vt100_output_string_esc,
114 1.1 drochner wsemul_vt100_output_dcs,
115 1.1 drochner wsemul_vt100_output_dcs_dollar,
116 1.1 drochner };
117 1.1 drochner
118 1.1 drochner static void
119 1.1 drochner wsemul_vt100_init(edp, type, cookie, ccol, crow, defattr)
120 1.1 drochner struct wsemul_vt100_emuldata *edp;
121 1.1 drochner const struct wsscreen_descr *type;
122 1.1 drochner void *cookie;
123 1.1 drochner int ccol, crow;
124 1.1 drochner long defattr;
125 1.1 drochner {
126 1.1 drochner edp->emulops = type->textops;
127 1.1 drochner edp->emulcookie = cookie;
128 1.1 drochner edp->scrcapabilities = type->capabilities;
129 1.1 drochner edp->nrows = type->nrows;
130 1.1 drochner edp->ncols = type->ncols;
131 1.1 drochner edp->crow = crow;
132 1.1 drochner edp->ccol = ccol;
133 1.1 drochner edp->defattr = defattr;
134 1.1 drochner }
135 1.1 drochner
136 1.1 drochner void *
137 1.1 drochner wsemul_vt100_cnattach(type, cookie, ccol, crow, defattr)
138 1.1 drochner const struct wsscreen_descr *type;
139 1.1 drochner void *cookie;
140 1.1 drochner int ccol, crow;
141 1.1 drochner long defattr;
142 1.1 drochner {
143 1.1 drochner struct wsemul_vt100_emuldata *edp;
144 1.1 drochner int res;
145 1.1 drochner
146 1.1 drochner edp = &wsemul_vt100_console_emuldata;
147 1.1 drochner wsemul_vt100_init(edp, type, cookie, ccol, crow, defattr);
148 1.1 drochner #ifdef DIAGNOSTIC
149 1.1 drochner edp->console = 1;
150 1.1 drochner #endif
151 1.1 drochner edp->cbcookie = NULL;
152 1.1 drochner
153 1.1 drochner #if defined(WS_KERNEL_FG) || defined(WS_KERNEL_BG) || \
154 1.1 drochner defined(WS_KERNEL_COLATTR) || defined(WS_KERNEL_MONOATTR)
155 1.1 drochner #ifndef WS_KERNEL_FG
156 1.1 drochner #define WS_KERNEL_FG WSCOL_WHITE
157 1.1 drochner #endif
158 1.1 drochner #ifndef WS_KERNEL_BG
159 1.1 drochner #define WS_KERNEL_BG WSCOL_BLACK
160 1.1 drochner #endif
161 1.1 drochner #ifndef WS_KERNEL_COLATTR
162 1.1 drochner #define WS_KERNEL_COLATTR 0
163 1.1 drochner #endif
164 1.1 drochner #ifndef WS_KERNEL_MONOATTR
165 1.1 drochner #define WS_KERNEL_MONOATTR 0
166 1.1 drochner #endif
167 1.1 drochner if (type->capabilities & WSSCREEN_WSCOLORS)
168 1.1 drochner res = (*edp->emulops->alloc_attr)(cookie,
169 1.1 drochner WS_KERNEL_FG, WS_KERNEL_BG,
170 1.1 drochner WS_KERNEL_COLATTR | WSATTR_WSCOLORS,
171 1.1 drochner &edp->kernattr);
172 1.1 drochner else
173 1.1 drochner res = (*edp->emulops->alloc_attr)(cookie, 0, 0,
174 1.1 drochner WS_KERNEL_MONOATTR,
175 1.1 drochner &edp->kernattr);
176 1.1 drochner if (res)
177 1.1 drochner #endif
178 1.1 drochner edp->kernattr = defattr;
179 1.1 drochner
180 1.1 drochner edp->tabs = 0;
181 1.3 drochner edp->dblwid = 0;
182 1.3 drochner edp->dw = 0;
183 1.1 drochner edp->dcsarg = 0;
184 1.3 drochner edp->isolatin1tab = edp->decgraphtab = edp->dectechtab = 0;
185 1.3 drochner edp->nrctab = 0;
186 1.1 drochner wsemul_vt100_reset(edp);
187 1.1 drochner return (edp);
188 1.1 drochner }
189 1.1 drochner
190 1.1 drochner void *
191 1.1 drochner wsemul_vt100_attach(console, type, cookie, ccol, crow, cbcookie, defattr)
192 1.1 drochner int console;
193 1.1 drochner const struct wsscreen_descr *type;
194 1.1 drochner void *cookie;
195 1.1 drochner int ccol, crow;
196 1.1 drochner void *cbcookie;
197 1.1 drochner long defattr;
198 1.1 drochner {
199 1.1 drochner struct wsemul_vt100_emuldata *edp;
200 1.1 drochner
201 1.1 drochner if (console) {
202 1.1 drochner edp = &wsemul_vt100_console_emuldata;
203 1.1 drochner #ifdef DIAGNOSTIC
204 1.1 drochner KASSERT(edp->console == 1);
205 1.1 drochner #endif
206 1.1 drochner } else {
207 1.1 drochner edp = malloc(sizeof *edp, M_DEVBUF, M_WAITOK);
208 1.1 drochner wsemul_vt100_init(edp, type, cookie, ccol, crow, defattr);
209 1.1 drochner #ifdef DIAGNOSTIC
210 1.1 drochner edp->console = 0;
211 1.1 drochner #endif
212 1.1 drochner }
213 1.1 drochner edp->cbcookie = cbcookie;
214 1.1 drochner
215 1.4 drochner edp->tabs = malloc(edp->ncols, M_DEVBUF, M_NOWAIT);
216 1.4 drochner edp->dblwid = malloc(edp->nrows, M_DEVBUF, M_NOWAIT);
217 1.4 drochner bzero(edp->dblwid, edp->nrows);
218 1.3 drochner edp->dw = 0;
219 1.1 drochner edp->dcsarg = malloc(DCS_MAXLEN, M_DEVBUF, M_NOWAIT);
220 1.3 drochner edp->isolatin1tab = malloc(128 * sizeof(int), M_DEVBUF, M_NOWAIT);
221 1.3 drochner edp->decgraphtab = malloc(128 * sizeof(int), M_DEVBUF, M_NOWAIT);
222 1.3 drochner edp->dectechtab = malloc(128 * sizeof(int), M_DEVBUF, M_NOWAIT);
223 1.3 drochner edp->nrctab = malloc(128 * sizeof(int), M_DEVBUF, M_NOWAIT);
224 1.3 drochner vt100_initchartables(edp);
225 1.1 drochner wsemul_vt100_reset(edp);
226 1.1 drochner return (edp);
227 1.1 drochner }
228 1.1 drochner
229 1.1 drochner void
230 1.1 drochner wsemul_vt100_detach(cookie, crowp, ccolp)
231 1.1 drochner void *cookie;
232 1.1 drochner u_int *crowp, *ccolp;
233 1.1 drochner {
234 1.1 drochner struct wsemul_vt100_emuldata *edp = cookie;
235 1.1 drochner
236 1.1 drochner *crowp = edp->crow;
237 1.1 drochner *ccolp = edp->ccol;
238 1.3 drochner #define f(ptr) if (ptr) {free(ptr, M_DEVBUF); ptr = 0;}
239 1.3 drochner f(edp->tabs)
240 1.3 drochner f(edp->dblwid)
241 1.3 drochner f(edp->dcsarg)
242 1.3 drochner f(edp->isolatin1tab)
243 1.3 drochner f(edp->decgraphtab)
244 1.3 drochner f(edp->dectechtab)
245 1.3 drochner f(edp->nrctab)
246 1.3 drochner #undef f
247 1.1 drochner if (edp != &wsemul_vt100_console_emuldata)
248 1.1 drochner free(edp, M_DEVBUF);
249 1.1 drochner }
250 1.1 drochner
251 1.1 drochner void
252 1.1 drochner wsemul_vt100_reset(edp)
253 1.1 drochner struct wsemul_vt100_emuldata *edp;
254 1.1 drochner {
255 1.1 drochner int i;
256 1.1 drochner
257 1.1 drochner edp->state = VT100_EMUL_STATE_NORMAL;
258 1.1 drochner edp->flags = VTFL_DECAWM | VTFL_CURSORON;
259 1.1 drochner edp->curattr = edp->defattr;
260 1.1 drochner edp->attrflags = 0;
261 1.1 drochner edp->fgcol = WSCOL_WHITE;
262 1.1 drochner edp->bgcol = WSCOL_BLACK;
263 1.1 drochner edp->scrreg_startrow = 0;
264 1.1 drochner edp->scrreg_nrows = edp->nrows;
265 1.1 drochner if (edp->tabs) {
266 1.1 drochner bzero(edp->tabs, edp->ncols);
267 1.1 drochner for (i = 1; i < edp->ncols; i += 8 - (i & 7))
268 1.1 drochner edp->tabs[i] = 1;
269 1.1 drochner }
270 1.1 drochner edp->dcspos = 0;
271 1.1 drochner edp->dcstype = 0;
272 1.3 drochner edp->chartab_G[0] = 0;
273 1.3 drochner edp->chartab_G[1] = edp->nrctab; /* ??? */
274 1.3 drochner edp->chartab_G[2] = edp->isolatin1tab;
275 1.3 drochner edp->chartab_G[3] = edp->isolatin1tab;
276 1.3 drochner edp->chartab0 = 0;
277 1.3 drochner edp->chartab1 = 2;
278 1.3 drochner edp->sschartab = 0;
279 1.1 drochner }
280 1.1 drochner
281 1.1 drochner /*
282 1.1 drochner * now all the state machine bits
283 1.1 drochner */
284 1.1 drochner
285 1.1 drochner static u_int
286 1.1 drochner wsemul_vt100_output_normal(edp, c, kernel)
287 1.1 drochner struct wsemul_vt100_emuldata *edp;
288 1.1 drochner u_char c;
289 1.1 drochner int kernel;
290 1.1 drochner {
291 1.1 drochner u_int newstate = VT100_EMUL_STATE_NORMAL;
292 1.3 drochner u_int n, dc;
293 1.3 drochner u_int *ct;
294 1.1 drochner
295 1.1 drochner switch (c) {
296 1.1 drochner case ASCII_NUL:
297 1.1 drochner /* ignore */
298 1.1 drochner break;
299 1.1 drochner case ASCII_BEL:
300 1.1 drochner wsdisplay_emulbell(edp->cbcookie);
301 1.1 drochner break;
302 1.1 drochner case ASCII_BS:
303 1.1 drochner if (edp->ccol > 0) {
304 1.1 drochner edp->ccol--;
305 1.1 drochner edp->flags &= ~VTFL_LASTCHAR;
306 1.1 drochner }
307 1.1 drochner break;
308 1.1 drochner case ASCII_CR:
309 1.1 drochner edp->ccol = 0;
310 1.1 drochner edp->flags &= ~VTFL_LASTCHAR;
311 1.1 drochner break;
312 1.1 drochner case ASCII_HT:
313 1.1 drochner if (edp->tabs) {
314 1.3 drochner if (!COLS_LEFT)
315 1.1 drochner break;
316 1.3 drochner for (n = edp->ccol + 1; n < NCOLS - 1; n++)
317 1.1 drochner if (edp->tabs[n])
318 1.1 drochner break;
319 1.1 drochner } else {
320 1.1 drochner n = edp->ccol + min(8 - (edp->ccol & 7), COLS_LEFT);
321 1.1 drochner }
322 1.3 drochner ERASECOLS(edp->ccol, n - edp->ccol,
323 1.3 drochner kernel ? edp->kernattr : edp->curattr);
324 1.1 drochner edp->ccol = n;
325 1.1 drochner break;
326 1.3 drochner case ASCII_SO: /* LS1 */
327 1.3 drochner edp->chartab0 = 1;
328 1.3 drochner break;
329 1.1 drochner case ASCII_SI: /* LS0 */
330 1.3 drochner edp->chartab0 = 0;
331 1.1 drochner break;
332 1.1 drochner case ASCII_ESC:
333 1.1 drochner #ifdef DIAGNOSTIC
334 1.1 drochner if (kernel)
335 1.1 drochner panic("ESC in kernel output");
336 1.1 drochner #endif
337 1.1 drochner newstate = VT100_EMUL_STATE_ESC;
338 1.1 drochner break;
339 1.1 drochner #if 0
340 1.1 drochner case CSI: /* 8-bit */
341 1.1 drochner edp->nargs = 0;
342 1.1 drochner bzero(edp->args, sizeof (edp->args));
343 1.3 drochner edp->modif1 = edp->modif2 = '\0';
344 1.1 drochner newstate = VT100_EMUL_STATE_CSI;
345 1.1 drochner break;
346 1.1 drochner case DCS: /* 8-bit */
347 1.1 drochner edp->nargs = 0;
348 1.1 drochner bzero(edp->args, sizeof (edp->args));
349 1.1 drochner newstate = VT100_EMUL_STATE_DCS;
350 1.1 drochner break;
351 1.1 drochner #endif
352 1.1 drochner default: /* normal character */
353 1.1 drochner if ((edp->flags & (VTFL_LASTCHAR | VTFL_DECAWM)) ==
354 1.1 drochner (VTFL_LASTCHAR | VTFL_DECAWM)) {
355 1.3 drochner if (ROWS_BELOW > 0) {
356 1.1 drochner edp->crow++;
357 1.3 drochner CHECK_DW;
358 1.3 drochner } else
359 1.1 drochner wsemul_vt100_scrollup(edp, 1);
360 1.1 drochner edp->ccol = 0;
361 1.1 drochner edp->flags &= ~VTFL_LASTCHAR;
362 1.1 drochner }
363 1.1 drochner
364 1.3 drochner if (c & 0x80) {
365 1.3 drochner c &= 0x7f;
366 1.3 drochner ct = edp->chartab_G[edp->chartab1];
367 1.3 drochner } else {
368 1.3 drochner if (edp->sschartab) {
369 1.3 drochner ct = edp->chartab_G[edp->sschartab];
370 1.3 drochner edp->sschartab = 0;
371 1.3 drochner } else
372 1.3 drochner ct = edp->chartab_G[edp->chartab0];
373 1.3 drochner }
374 1.3 drochner dc = (ct ? ct[c] : c);
375 1.3 drochner
376 1.3 drochner if ((edp->flags & VTFL_INSERTMODE) && COLS_LEFT)
377 1.3 drochner COPYCOLS(edp->ccol, edp->ccol + 1, COLS_LEFT);
378 1.3 drochner
379 1.3 drochner (*edp->emulops->putchar)(edp->emulcookie, edp->crow,
380 1.3 drochner edp->ccol << edp->dw, dc,
381 1.3 drochner kernel ? edp->kernattr : edp->curattr);
382 1.1 drochner
383 1.3 drochner if (COLS_LEFT)
384 1.1 drochner edp->ccol++;
385 1.1 drochner else
386 1.1 drochner edp->flags |= VTFL_LASTCHAR;
387 1.1 drochner break;
388 1.1 drochner case ASCII_LF:
389 1.1 drochner case ASCII_VT:
390 1.1 drochner case ASCII_FF:
391 1.3 drochner if (ROWS_BELOW > 0) {
392 1.1 drochner edp->crow++;
393 1.3 drochner CHECK_DW;
394 1.3 drochner } else
395 1.1 drochner wsemul_vt100_scrollup(edp, 1);
396 1.1 drochner break;
397 1.1 drochner }
398 1.1 drochner
399 1.1 drochner return (newstate);
400 1.1 drochner }
401 1.1 drochner
402 1.1 drochner static u_int
403 1.1 drochner wsemul_vt100_output_esc(edp, c)
404 1.1 drochner struct wsemul_vt100_emuldata *edp;
405 1.1 drochner u_char c;
406 1.1 drochner {
407 1.1 drochner u_int newstate = VT100_EMUL_STATE_NORMAL;
408 1.3 drochner int i;
409 1.1 drochner
410 1.1 drochner switch (c) {
411 1.1 drochner case '[': /* CSI */
412 1.1 drochner edp->nargs = 0;
413 1.1 drochner bzero(edp->args, sizeof (edp->args));
414 1.3 drochner edp->modif1 = edp->modif2 = '\0';
415 1.1 drochner newstate = VT100_EMUL_STATE_CSI;
416 1.1 drochner break;
417 1.1 drochner case '7': /* DECSC */
418 1.1 drochner edp->savedcursor_row = edp->crow;
419 1.1 drochner edp->savedcursor_col = edp->ccol;
420 1.3 drochner edp->savedattr = edp->curattr;
421 1.3 drochner edp->savedattrflags = edp->attrflags;
422 1.3 drochner edp->savedfgcol = edp->fgcol;
423 1.3 drochner edp->savedbgcol = edp->bgcol;
424 1.3 drochner for (i = 0; i < 4; i++)
425 1.3 drochner edp->savedchartab_G[i] = edp->chartab_G[i];
426 1.3 drochner edp->savedchartab0 = edp->chartab0;
427 1.3 drochner edp->savedchartab1 = edp->chartab1;
428 1.1 drochner break;
429 1.1 drochner case '8': /* DECRC */
430 1.1 drochner edp->crow = edp->savedcursor_row;
431 1.1 drochner edp->ccol = edp->savedcursor_col;
432 1.3 drochner edp->curattr = edp->savedattr;
433 1.3 drochner edp->attrflags = edp->savedattrflags;
434 1.3 drochner edp->fgcol = edp->savedfgcol;
435 1.3 drochner edp->bgcol = edp->savedbgcol;
436 1.3 drochner for (i = 0; i < 4; i++)
437 1.3 drochner edp->chartab_G[i] = edp->savedchartab_G[i];
438 1.3 drochner edp->chartab0 = edp->savedchartab0;
439 1.3 drochner edp->chartab1 = edp->savedchartab1;
440 1.1 drochner break;
441 1.1 drochner case '=': /* DECKPAM application mode */
442 1.1 drochner edp->flags |= VTFL_APPLKEYPAD;
443 1.1 drochner break;
444 1.1 drochner case '>': /* DECKPNM numeric mode */
445 1.1 drochner edp->flags &= ~VTFL_APPLKEYPAD;
446 1.1 drochner break;
447 1.1 drochner case 'E': /* NEL */
448 1.1 drochner edp->ccol = 0;
449 1.1 drochner /* FALLTHRU */
450 1.1 drochner case 'D': /* IND */
451 1.1 drochner if (ROWS_BELOW > 0) {
452 1.1 drochner edp->crow++;
453 1.3 drochner CHECK_DW;
454 1.1 drochner break;
455 1.1 drochner }
456 1.1 drochner wsemul_vt100_scrollup(edp, 1);
457 1.1 drochner break;
458 1.1 drochner case 'H': /* HTS */
459 1.1 drochner KASSERT(edp->tabs != 0);
460 1.1 drochner edp->tabs[edp->ccol] = 1;
461 1.1 drochner break;
462 1.1 drochner case '~': /* LS1R */
463 1.3 drochner edp->chartab1 = 1;
464 1.3 drochner break;
465 1.1 drochner case 'n': /* LS2 */
466 1.3 drochner edp->chartab0 = 2;
467 1.3 drochner break;
468 1.1 drochner case '}': /* LS2R */
469 1.3 drochner edp->chartab1 = 2;
470 1.3 drochner break;
471 1.1 drochner case 'o': /* LS3 */
472 1.3 drochner edp->chartab0 = 3;
473 1.3 drochner break;
474 1.1 drochner case '|': /* LS3R */
475 1.3 drochner edp->chartab1 = 3;
476 1.1 drochner break;
477 1.1 drochner case 'N': /* SS2 */
478 1.3 drochner edp->sschartab = 2;
479 1.3 drochner break;
480 1.1 drochner case 'O': /* SS3 */
481 1.3 drochner edp->sschartab = 3;
482 1.1 drochner break;
483 1.1 drochner case 'M': /* RI */
484 1.1 drochner if (ROWS_ABOVE > 0) {
485 1.1 drochner edp->crow--;
486 1.3 drochner CHECK_DW;
487 1.1 drochner break;
488 1.1 drochner }
489 1.1 drochner wsemul_vt100_scrolldown(edp, 1);
490 1.1 drochner break;
491 1.1 drochner case 'P': /* DCS */
492 1.1 drochner edp->nargs = 0;
493 1.1 drochner bzero(edp->args, sizeof (edp->args));
494 1.1 drochner newstate = VT100_EMUL_STATE_DCS;
495 1.1 drochner break;
496 1.1 drochner case 'c': /* RIS */
497 1.1 drochner wsemul_vt100_reset(edp);
498 1.3 drochner wsemul_vt100_ed(edp, 2);
499 1.1 drochner edp->ccol = edp->crow = 0;
500 1.1 drochner break;
501 1.1 drochner case '(': case ')': case '*': case '+': /* SCS */
502 1.3 drochner edp->designating = c - '(';
503 1.1 drochner newstate = VT100_EMUL_STATE_SCS94;
504 1.1 drochner break;
505 1.1 drochner case '-': case '.': case '/': /* SCS */
506 1.3 drochner edp->designating = c - '-' + 1;
507 1.1 drochner newstate = VT100_EMUL_STATE_SCS96;
508 1.1 drochner break;
509 1.1 drochner case '#':
510 1.3 drochner newstate = VT100_EMUL_STATE_ESC_HASH;
511 1.1 drochner break;
512 1.1 drochner case ' ': /* 7/8 bit */
513 1.1 drochner newstate = VT100_EMUL_STATE_ESC_SPC;
514 1.1 drochner break;
515 1.1 drochner case ']': /* OSC operating system command */
516 1.1 drochner case '^': /* PM privacy message */
517 1.1 drochner case '_': /* APC application program command */
518 1.1 drochner /* ignored */
519 1.1 drochner newstate = VT100_EMUL_STATE_STRING;
520 1.1 drochner break;
521 1.1 drochner case '<': /* exit VT52 mode - ignored */
522 1.1 drochner break;
523 1.1 drochner default:
524 1.1 drochner #ifdef VT100_PRINTUNKNOWN
525 1.1 drochner printf("ESC%c unknown\n", c);
526 1.1 drochner #endif
527 1.1 drochner break;
528 1.1 drochner }
529 1.1 drochner
530 1.1 drochner return (newstate);
531 1.1 drochner }
532 1.1 drochner
533 1.1 drochner static u_int
534 1.1 drochner wsemul_vt100_output_scs94(edp, c)
535 1.1 drochner struct wsemul_vt100_emuldata *edp;
536 1.1 drochner u_char c;
537 1.1 drochner {
538 1.1 drochner u_int newstate = VT100_EMUL_STATE_NORMAL;
539 1.1 drochner
540 1.1 drochner switch (c) {
541 1.1 drochner case '%': /* probably DEC supplemental graphic */
542 1.1 drochner newstate = VT100_EMUL_STATE_SCS94_PERCENT;
543 1.1 drochner break;
544 1.3 drochner case 'A': /* british / national */
545 1.3 drochner edp->chartab_G[edp->designating] = edp->nrctab;
546 1.3 drochner break;
547 1.1 drochner case 'B': /* ASCII */
548 1.3 drochner edp->chartab_G[edp->designating] = 0;
549 1.3 drochner break;
550 1.1 drochner case '<': /* user preferred supplemental */
551 1.3 drochner /* XXX not really "user" preferred */
552 1.3 drochner edp->chartab_G[edp->designating] = edp->isolatin1tab;
553 1.3 drochner break;
554 1.1 drochner case '0': /* DEC special graphic */
555 1.3 drochner edp->chartab_G[edp->designating] = edp->decgraphtab;
556 1.3 drochner break;
557 1.3 drochner case '>': /* DEC tech */
558 1.3 drochner edp->chartab_G[edp->designating] = edp->dectechtab;
559 1.1 drochner break;
560 1.1 drochner default:
561 1.1 drochner #ifdef VT100_PRINTUNKNOWN
562 1.3 drochner printf("ESC%c%c unknown\n", edp->designating + '(', c);
563 1.1 drochner #endif
564 1.1 drochner break;
565 1.1 drochner }
566 1.1 drochner return (newstate);
567 1.1 drochner }
568 1.1 drochner
569 1.1 drochner static u_int
570 1.1 drochner wsemul_vt100_output_scs94_percent(edp, c)
571 1.1 drochner struct wsemul_vt100_emuldata *edp;
572 1.1 drochner u_char c;
573 1.1 drochner {
574 1.1 drochner switch (c) {
575 1.1 drochner case '5': /* DEC supplemental graphic */
576 1.3 drochner /* XXX there are differences */
577 1.3 drochner edp->chartab_G[edp->designating] = edp->isolatin1tab;
578 1.1 drochner break;
579 1.1 drochner default:
580 1.1 drochner #ifdef VT100_PRINTUNKNOWN
581 1.3 drochner printf("ESC%c%%%c unknown\n", edp->designating + '(', c);
582 1.1 drochner #endif
583 1.1 drochner break;
584 1.1 drochner }
585 1.1 drochner return (VT100_EMUL_STATE_NORMAL);
586 1.1 drochner }
587 1.1 drochner
588 1.1 drochner static u_int
589 1.1 drochner wsemul_vt100_output_scs96(edp, c)
590 1.1 drochner struct wsemul_vt100_emuldata *edp;
591 1.1 drochner u_char c;
592 1.1 drochner {
593 1.1 drochner u_int newstate = VT100_EMUL_STATE_NORMAL;
594 1.3 drochner int nrc;
595 1.1 drochner
596 1.1 drochner switch (c) {
597 1.1 drochner case '%': /* probably portugese */
598 1.1 drochner newstate = VT100_EMUL_STATE_SCS96_PERCENT;
599 1.1 drochner break;
600 1.3 drochner case 'A': /* ISO-latin-1 supplemental */
601 1.3 drochner edp->chartab_G[edp->designating] = edp->isolatin1tab;
602 1.3 drochner break;
603 1.1 drochner case '4': /* dutch */
604 1.3 drochner nrc = 1;
605 1.3 drochner goto setnrc;
606 1.1 drochner case '5': case 'C': /* finnish */
607 1.3 drochner nrc = 2;
608 1.3 drochner goto setnrc;
609 1.1 drochner case 'R': /* french */
610 1.3 drochner nrc = 3;
611 1.3 drochner goto setnrc;
612 1.1 drochner case 'Q': /* french canadian */
613 1.3 drochner nrc = 4;
614 1.3 drochner goto setnrc;
615 1.1 drochner case 'K': /* german */
616 1.3 drochner nrc = 5;
617 1.3 drochner goto setnrc;
618 1.1 drochner case 'Y': /* italian */
619 1.3 drochner nrc = 6;
620 1.3 drochner goto setnrc;
621 1.1 drochner case 'E': case '6': /* norwegian / danish */
622 1.3 drochner nrc = 7;
623 1.3 drochner goto setnrc;
624 1.1 drochner case 'Z': /* spanish */
625 1.3 drochner nrc = 9;
626 1.3 drochner goto setnrc;
627 1.1 drochner case '7': case 'H': /* swedish */
628 1.3 drochner nrc = 10;
629 1.3 drochner goto setnrc;
630 1.1 drochner case '=': /* swiss */
631 1.3 drochner nrc = 11;
632 1.3 drochner setnrc:
633 1.3 drochner vt100_setnrc(edp, nrc); /* what table ??? */
634 1.1 drochner break;
635 1.1 drochner default:
636 1.1 drochner #ifdef VT100_PRINTUNKNOWN
637 1.3 drochner printf("ESC%c%c unknown\n", edp->designating + '-' - 1, c);
638 1.1 drochner #endif
639 1.1 drochner break;
640 1.1 drochner }
641 1.1 drochner return (newstate);
642 1.1 drochner }
643 1.1 drochner
644 1.1 drochner static u_int
645 1.1 drochner wsemul_vt100_output_scs96_percent(edp, c)
646 1.1 drochner struct wsemul_vt100_emuldata *edp;
647 1.1 drochner u_char c;
648 1.1 drochner {
649 1.1 drochner switch (c) {
650 1.1 drochner case '6': /* portugese */
651 1.3 drochner vt100_setnrc(edp, 8);
652 1.1 drochner break;
653 1.1 drochner default:
654 1.1 drochner #ifdef VT100_PRINTUNKNOWN
655 1.3 drochner printf("ESC%c%%%c unknown\n", edp->designating + '-', c);
656 1.1 drochner #endif
657 1.1 drochner break;
658 1.1 drochner }
659 1.1 drochner return (VT100_EMUL_STATE_NORMAL);
660 1.1 drochner }
661 1.1 drochner
662 1.1 drochner static u_int
663 1.1 drochner wsemul_vt100_output_esc_spc(edp, c)
664 1.1 drochner struct wsemul_vt100_emuldata *edp;
665 1.1 drochner u_char c;
666 1.1 drochner {
667 1.1 drochner switch (c) {
668 1.1 drochner case 'F': /* 7-bit controls */
669 1.1 drochner case 'G': /* 8-bit controls */
670 1.1 drochner #ifdef VT100_PRINTNOTIMPL
671 1.1 drochner printf("ESC<SPC>%c ignored\n", c);
672 1.1 drochner #endif
673 1.1 drochner break;
674 1.1 drochner default:
675 1.1 drochner #ifdef VT100_PRINTUNKNOWN
676 1.1 drochner printf("ESC<SPC>%c unknown\n", c);
677 1.1 drochner #endif
678 1.1 drochner break;
679 1.1 drochner }
680 1.1 drochner return (VT100_EMUL_STATE_NORMAL);
681 1.1 drochner }
682 1.1 drochner
683 1.1 drochner static u_int
684 1.1 drochner wsemul_vt100_output_string(edp, c)
685 1.1 drochner struct wsemul_vt100_emuldata *edp;
686 1.1 drochner u_char c;
687 1.1 drochner {
688 1.1 drochner switch (c) {
689 1.1 drochner case ASCII_ESC: /* might be a string end */
690 1.1 drochner return (VT100_EMUL_STATE_STRING_ESC);
691 1.1 drochner #if 0
692 1.1 drochner case ST: /* string end 8-bit */
693 1.1 drochner wsemul_vt100_handle_dcs(edp);
694 1.1 drochner return (VT100_EMUL_STATE_NORMAL);
695 1.1 drochner #endif
696 1.1 drochner default:
697 1.1 drochner if (edp->dcstype && edp->dcspos < DCS_MAXLEN)
698 1.1 drochner edp->dcsarg[edp->dcspos++] = c;
699 1.1 drochner }
700 1.1 drochner return (VT100_EMUL_STATE_STRING);
701 1.1 drochner }
702 1.1 drochner
703 1.1 drochner static u_int
704 1.1 drochner wsemul_vt100_output_string_esc(edp, c)
705 1.1 drochner struct wsemul_vt100_emuldata *edp;
706 1.1 drochner u_char c;
707 1.1 drochner {
708 1.1 drochner if (c == '\\') { /* ST complete */
709 1.1 drochner wsemul_vt100_handle_dcs(edp);
710 1.1 drochner return (VT100_EMUL_STATE_NORMAL);
711 1.1 drochner } else
712 1.1 drochner return (VT100_EMUL_STATE_STRING);
713 1.1 drochner }
714 1.1 drochner
715 1.1 drochner static u_int
716 1.1 drochner wsemul_vt100_output_dcs(edp, c)
717 1.1 drochner struct wsemul_vt100_emuldata *edp;
718 1.1 drochner u_char c;
719 1.1 drochner {
720 1.1 drochner u_int newstate = VT100_EMUL_STATE_DCS;
721 1.1 drochner
722 1.1 drochner switch (c) {
723 1.1 drochner case '0': case '1': case '2': case '3': case '4':
724 1.1 drochner case '5': case '6': case '7': case '8': case '9':
725 1.1 drochner /* argument digit */
726 1.1 drochner if (edp->nargs > VT100_EMUL_NARGS - 1)
727 1.1 drochner break;
728 1.1 drochner edp->args[edp->nargs] = (edp->args[edp->nargs] * 10) +
729 1.1 drochner (c - '0');
730 1.1 drochner break;
731 1.1 drochner case ';': /* argument terminator */
732 1.1 drochner edp->nargs++;
733 1.1 drochner break;
734 1.1 drochner default:
735 1.1 drochner edp->nargs++;
736 1.1 drochner if (edp->nargs > VT100_EMUL_NARGS) {
737 1.1 drochner #ifdef VT100_DEBUG
738 1.1 drochner printf("vt100: too many arguments\n");
739 1.1 drochner #endif
740 1.1 drochner edp->nargs = VT100_EMUL_NARGS;
741 1.1 drochner }
742 1.1 drochner newstate = VT100_EMUL_STATE_STRING;
743 1.1 drochner switch (c) {
744 1.1 drochner case '$':
745 1.1 drochner newstate = VT100_EMUL_STATE_DCS_DOLLAR;
746 1.1 drochner break;
747 1.1 drochner case '{': /* DECDLD soft charset */
748 1.1 drochner case '!': /* DECRQUPSS user preferred supplemental set */
749 1.1 drochner /* 'u' must follow - need another state */
750 1.1 drochner case '|': /* DECUDK program F6..F20 */
751 1.1 drochner #ifdef VT100_PRINTNOTIMPL
752 1.1 drochner printf("DCS%c ignored\n", c);
753 1.1 drochner #endif
754 1.1 drochner break;
755 1.1 drochner default:
756 1.1 drochner #ifdef VT100_PRINTUNKNOWN
757 1.1 drochner printf("DCS%c (%d, %d) unknown\n", c, ARG(0), ARG(1));
758 1.1 drochner #endif
759 1.1 drochner break;
760 1.1 drochner }
761 1.1 drochner }
762 1.1 drochner
763 1.1 drochner return (newstate);
764 1.1 drochner }
765 1.1 drochner
766 1.1 drochner static u_int
767 1.1 drochner wsemul_vt100_output_dcs_dollar(edp, c)
768 1.1 drochner struct wsemul_vt100_emuldata *edp;
769 1.1 drochner u_char c;
770 1.1 drochner {
771 1.1 drochner switch (c) {
772 1.1 drochner case 'p': /* DECRSTS terminal state restore */
773 1.1 drochner case 'q': /* DECRQSS control function request */
774 1.1 drochner #ifdef VT100_PRINTNOTIMPL
775 1.1 drochner printf("DCS$%c ignored\n", c);
776 1.1 drochner #endif
777 1.1 drochner break;
778 1.1 drochner case 't': /* DECRSPS restore presentation state */
779 1.1 drochner switch (ARG(0)) {
780 1.1 drochner case 0: /* error */
781 1.1 drochner break;
782 1.1 drochner case 1: /* cursor information restore */
783 1.1 drochner #ifdef VT100_PRINTNOTIMPL
784 1.1 drochner printf("DCS1$t ignored\n");
785 1.1 drochner #endif
786 1.1 drochner break;
787 1.1 drochner case 2: /* tab stop restore */
788 1.1 drochner edp->dcspos = 0;
789 1.1 drochner edp->dcstype = DCSTYPE_TABRESTORE;
790 1.1 drochner break;
791 1.1 drochner default:
792 1.1 drochner #ifdef VT100_PRINTUNKNOWN
793 1.1 drochner printf("DCS%d$t unknown\n", ARG(0));
794 1.1 drochner #endif
795 1.1 drochner break;
796 1.1 drochner }
797 1.1 drochner break;
798 1.1 drochner default:
799 1.1 drochner #ifdef VT100_PRINTUNKNOWN
800 1.1 drochner printf("DCS$%c (%d, %d) unknown\n", c, ARG(0), ARG(1));
801 1.1 drochner #endif
802 1.1 drochner break;
803 1.1 drochner }
804 1.1 drochner return (VT100_EMUL_STATE_STRING);
805 1.1 drochner }
806 1.1 drochner
807 1.1 drochner static u_int
808 1.3 drochner wsemul_vt100_output_esc_hash(edp, c)
809 1.1 drochner struct wsemul_vt100_emuldata *edp;
810 1.1 drochner u_char c;
811 1.1 drochner {
812 1.3 drochner int i;
813 1.1 drochner
814 1.1 drochner switch (c) {
815 1.3 drochner case '5': /* DECSWL single width, single height */
816 1.3 drochner if (edp->dw) {
817 1.3 drochner for (i = 0; i < edp->ncols / 2; i++)
818 1.3 drochner (*edp->emulops->copycols)(edp->emulcookie,
819 1.3 drochner edp->crow,
820 1.3 drochner 2 * i, i, 1);
821 1.3 drochner (*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
822 1.3 drochner i, edp->ncols - i,
823 1.3 drochner edp->defattr);
824 1.3 drochner edp->dblwid[edp->crow] = 0;
825 1.3 drochner edp->dw = 0;
826 1.1 drochner }
827 1.1 drochner break;
828 1.1 drochner case '6': /* DECDWL double width, single height */
829 1.1 drochner case '3': /* DECDHL double width, double height, top half */
830 1.1 drochner case '4': /* DECDHL double width, double height, bottom half */
831 1.3 drochner if (!edp->dw) {
832 1.3 drochner for (i = edp->ncols / 2 - 1; i >= 0; i--)
833 1.3 drochner (*edp->emulops->copycols)(edp->emulcookie,
834 1.3 drochner edp->crow,
835 1.3 drochner i, 2 * i, 1);
836 1.3 drochner for (i = 0; i < edp->ncols / 2; i++)
837 1.3 drochner (*edp->emulops->erasecols)(edp->emulcookie,
838 1.3 drochner edp->crow,
839 1.3 drochner 2 * i + 1, 1,
840 1.3 drochner edp->defattr);
841 1.3 drochner edp->dblwid[edp->crow] = 1;
842 1.3 drochner edp->dw = 1;
843 1.3 drochner if (edp->ccol > (edp->ncols >> 1) - 1)
844 1.3 drochner edp->ccol = (edp->ncols >> 1) - 1;
845 1.3 drochner }
846 1.1 drochner break;
847 1.1 drochner case '8': { /* DECALN */
848 1.1 drochner int i, j;
849 1.1 drochner for (i = 0; i < edp->nrows; i++)
850 1.1 drochner for (j = 0; j < edp->ncols; j++)
851 1.2 drochner (*edp->emulops->putchar)(edp->emulcookie, i, j,
852 1.2 drochner 'E', edp->curattr);
853 1.1 drochner }
854 1.1 drochner edp->ccol = 0;
855 1.1 drochner edp->crow = 0;
856 1.1 drochner break;
857 1.1 drochner default:
858 1.1 drochner #ifdef VT100_PRINTUNKNOWN
859 1.1 drochner printf("ESC#%c unknown\n", c);
860 1.1 drochner #endif
861 1.1 drochner break;
862 1.1 drochner }
863 1.1 drochner return (VT100_EMUL_STATE_NORMAL);
864 1.1 drochner }
865 1.1 drochner
866 1.1 drochner static u_int
867 1.1 drochner wsemul_vt100_output_csi(edp, c)
868 1.1 drochner struct wsemul_vt100_emuldata *edp;
869 1.1 drochner u_char c;
870 1.1 drochner {
871 1.1 drochner u_int newstate = VT100_EMUL_STATE_CSI;
872 1.1 drochner
873 1.1 drochner switch (c) {
874 1.1 drochner case '0': case '1': case '2': case '3': case '4':
875 1.1 drochner case '5': case '6': case '7': case '8': case '9':
876 1.1 drochner /* argument digit */
877 1.1 drochner if (edp->nargs > VT100_EMUL_NARGS - 1)
878 1.1 drochner break;
879 1.1 drochner edp->args[edp->nargs] = (edp->args[edp->nargs] * 10) +
880 1.1 drochner (c - '0');
881 1.1 drochner break;
882 1.1 drochner case ';': /* argument terminator */
883 1.1 drochner edp->nargs++;
884 1.1 drochner break;
885 1.1 drochner case '?': /* DEC specific */
886 1.1 drochner case '>': /* DA query */
887 1.3 drochner edp->modif1 = c;
888 1.1 drochner break;
889 1.3 drochner case '!':
890 1.1 drochner case '"':
891 1.1 drochner case '$':
892 1.1 drochner case '&':
893 1.3 drochner edp->modif2 = c;
894 1.1 drochner break;
895 1.1 drochner default: /* end of escape sequence */
896 1.1 drochner edp->nargs++;
897 1.1 drochner if (edp->nargs > VT100_EMUL_NARGS) {
898 1.1 drochner #ifdef VT100_DEBUG
899 1.1 drochner printf("vt100: too many arguments\n");
900 1.1 drochner #endif
901 1.1 drochner edp->nargs = VT100_EMUL_NARGS;
902 1.1 drochner }
903 1.1 drochner wsemul_vt100_handle_csi(edp, c);
904 1.1 drochner newstate = VT100_EMUL_STATE_NORMAL;
905 1.1 drochner break;
906 1.1 drochner }
907 1.1 drochner return (newstate);
908 1.1 drochner }
909 1.1 drochner
910 1.1 drochner void
911 1.1 drochner wsemul_vt100_output(cookie, data, count, kernel)
912 1.1 drochner void *cookie;
913 1.1 drochner const u_char *data;
914 1.1 drochner u_int count;
915 1.1 drochner int kernel;
916 1.1 drochner {
917 1.1 drochner struct wsemul_vt100_emuldata *edp = cookie;
918 1.1 drochner
919 1.1 drochner #ifdef DIAGNOSTIC
920 1.1 drochner if (kernel && !edp->console)
921 1.1 drochner panic("wsemul_vt100_output: kernel output, not console");
922 1.1 drochner #endif
923 1.1 drochner
924 1.1 drochner /* XXX */
925 1.3 drochner (*edp->emulops->cursor)(edp->emulcookie, 0,
926 1.3 drochner edp->crow, edp->ccol << edp->dw);
927 1.1 drochner for (; count > 0; data++, count--) {
928 1.1 drochner if (edp->state == VT100_EMUL_STATE_NORMAL || kernel) {
929 1.1 drochner edp->state = wsemul_vt100_output_normal(edp, *data,
930 1.1 drochner kernel);
931 1.1 drochner continue;
932 1.1 drochner }
933 1.1 drochner #ifdef DIAGNOSTIC
934 1.1 drochner if (edp->state > sizeof(vt100_output) / sizeof(vt100_output[0]))
935 1.1 drochner panic("wsemul_vt100: invalid state %d\n", edp->state);
936 1.1 drochner #endif
937 1.1 drochner edp->state = vt100_output[edp->state - 1](edp, *data);
938 1.1 drochner }
939 1.1 drochner /* XXX */
940 1.1 drochner (*edp->emulops->cursor)(edp->emulcookie, edp->flags & VTFL_CURSORON,
941 1.3 drochner edp->crow, edp->ccol << edp->dw);
942 1.1 drochner }
943