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