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