1 /* $NetBSD: wsemul_vt100_subr.c,v 1.14.2.4 2005/11/10 14:08:43 skrll Exp $ */
5 * Matthias Drochner. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #include <sys/cdefs.h>
30 __KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_subr.c,v 1.14.2.4 2005/11/10 14:08:43 skrll Exp $");
32 #include <sys/param.h>
33 #include <sys/systm.h>
35 #include <dev/wscons/wsconsio.h>
36 #include <dev/wscons/wsksymvar.h>
37 #include <dev/wscons/wsdisplayvar.h>
38 #include <dev/wscons/wsemulvar.h>
39 #include <dev/wscons/wsemul_vt100var.h>
41 #include "opt_wsemul.h"
43 static int vt100_selectattribute(struct wsemul_vt100_emuldata
*,
44 int, int, int, long *, long *);
45 static int vt100_ansimode(struct wsemul_vt100_emuldata
*, int, int);
46 static int vt100_decmode(struct wsemul_vt100_emuldata
*, int, int);
48 #define VTMODE_RESET 44
49 #define VTMODE_REPORT 55
52 * scroll up within scrolling region
55 wsemul_vt100_scrollup(struct wsemul_vt100_emuldata
*edp
, int n
)
59 if (n
> edp
->scrreg_nrows
)
60 n
= edp
->scrreg_nrows
;
62 help
= edp
->scrreg_nrows
- n
;
64 (*edp
->emulops
->copyrows
)(edp
->emulcookie
,
65 edp
->scrreg_startrow
+ n
,
69 memmove(&edp
->dblwid
[edp
->scrreg_startrow
],
70 &edp
->dblwid
[edp
->scrreg_startrow
+ n
],
73 (*edp
->emulops
->eraserows
)(edp
->emulcookie
,
74 edp
->scrreg_startrow
+ help
, n
,
77 memset(&edp
->dblwid
[edp
->scrreg_startrow
+ help
], 0, n
);
82 * scroll down within scrolling region
85 wsemul_vt100_scrolldown(struct wsemul_vt100_emuldata
*edp
, int n
)
89 if (n
> edp
->scrreg_nrows
)
90 n
= edp
->scrreg_nrows
;
92 help
= edp
->scrreg_nrows
- n
;
94 (*edp
->emulops
->copyrows
)(edp
->emulcookie
,
96 edp
->scrreg_startrow
+ n
,
99 memmove(&edp
->dblwid
[edp
->scrreg_startrow
+ n
],
100 &edp
->dblwid
[edp
->scrreg_startrow
],
103 (*edp
->emulops
->eraserows
)(edp
->emulcookie
,
104 edp
->scrreg_startrow
, n
,
107 memset(&edp
->dblwid
[edp
->scrreg_startrow
], 0, n
);
115 wsemul_vt100_ed(struct wsemul_vt100_emuldata
*edp
, int arg
)
120 case 0: /* cursor to end */
121 ERASECOLS(edp
->ccol
, COLS_LEFT
+ 1, edp
->bkgdattr
);
122 n
= edp
->nrows
- edp
->crow
- 1;
124 (*edp
->emulops
->eraserows
)(edp
->emulcookie
,
128 memset(&edp
->dblwid
[edp
->crow
+ 1], 0, n
);
131 case 1: /* beginning to cursor */
133 (*edp
->emulops
->eraserows
)(edp
->emulcookie
,
137 memset(&edp
->dblwid
[0], 0, edp
->crow
);
139 ERASECOLS(0, edp
->ccol
+ 1, edp
->bkgdattr
);
141 case 2: /* complete display */
142 (*edp
->emulops
->eraserows
)(edp
->emulcookie
,
146 memset(&edp
->dblwid
[0], 0, edp
->nrows
);
149 #ifdef VT100_PRINTUNKNOWN
150 printf("ed(%d) unknown\n", arg
);
161 wsemul_vt100_el(struct wsemul_vt100_emuldata
*edp
, int arg
)
164 case 0: /* cursor to end */
165 ERASECOLS(edp
->ccol
, COLS_LEFT
+ 1, edp
->bkgdattr
);
167 case 1: /* beginning to cursor */
168 ERASECOLS(0, edp
->ccol
+ 1, edp
->bkgdattr
);
170 case 2: /* complete line */
171 (*edp
->emulops
->erasecols
)(edp
->emulcookie
, edp
->crow
,
176 #ifdef VT100_PRINTUNKNOWN
177 printf("el(%d) unknown\n", arg
);
184 * handle commands after CSI (ESC[)
187 wsemul_vt100_handle_csi(struct wsemul_vt100_emuldata
*edp
, u_char c
)
189 int n
, help
, flags
, fgcol
, bgcol
;
192 #define A3(a, b, c) (((a) << 16) | ((b) << 8) | (c))
193 switch (A3(edp
->modif1
, edp
->modif2
, c
)) {
194 case A3('>', '\0', 'c'): /* DA secondary */
195 wsdisplay_emulinput(edp
->cbcookie
, WSEMUL_VT_ID2
,
196 sizeof(WSEMUL_VT_ID2
));
199 case A3('\0', '\0', 'J'): /* ED selective erase in display */
200 case A3('?', '\0', 'J'): /* DECSED selective erase in display */
201 wsemul_vt100_ed(edp
, ARG(0));
203 case A3('\0', '\0', 'K'): /* EL selective erase in line */
204 case A3('?', '\0', 'K'): /* DECSEL selective erase in line */
205 wsemul_vt100_el(edp
, ARG(0));
207 case A3('\0', '\0', 'h'): /* SM */
208 for (n
= 0; n
< edp
->nargs
; n
++)
209 vt100_ansimode(edp
, ARG(n
), VTMODE_SET
);
211 case A3('?', '\0', 'h'): /* DECSM */
212 for (n
= 0; n
< edp
->nargs
; n
++)
213 vt100_decmode(edp
, ARG(n
), VTMODE_SET
);
215 case A3('\0', '\0', 'l'): /* RM */
216 for (n
= 0; n
< edp
->nargs
; n
++)
217 vt100_ansimode(edp
, ARG(n
), VTMODE_RESET
);
219 case A3('?', '\0', 'l'): /* DECRM */
220 for (n
= 0; n
< edp
->nargs
; n
++)
221 vt100_decmode(edp
, ARG(n
), VTMODE_RESET
);
223 case A3('\0', '$', 'p'): /* DECRQM request mode ANSI */
224 vt100_ansimode(edp
, ARG(0), VTMODE_REPORT
);
226 case A3('?', '$', 'p'): /* DECRQM request mode DEC */
227 vt100_decmode(edp
, ARG(0), VTMODE_REPORT
);
229 case A3('\0', '\0', 'i'): /* MC printer controller mode */
230 case A3('?', '\0', 'i'): /* MC printer controller mode */
232 case 0: /* print screen */
233 case 1: /* print cursor line */
236 #ifdef VT100_PRINTNOTIMPL
237 printf("CSI%di ignored\n", ARG(0));
241 #ifdef VT100_PRINTUNKNOWN
242 printf("CSI%di unknown\n", ARG(0));
248 #define A2(a, b) (((a) << 8) | (b))
249 case A2('!', 'p'): /* DECSTR soft reset VT300 only */
250 wsemul_vt100_reset(edp
);
253 case A2('"', 'p'): /* DECSCL */
255 case 61: /* VT100 mode (no further arguments!) */
258 case 63: /* VT300 mode */
261 #ifdef VT100_PRINTUNKNOWN
262 printf("CSI%d\"p unknown\n", ARG(0));
268 case 2: /* 8-bit controls */
269 #ifdef VT100_PRINTNOTIMPL
270 printf("CSI%d;%d\"p ignored\n", ARG(0), ARG(1));
273 case 1: /* 7-bit controls */
276 #ifdef VT100_PRINTUNKNOWN
277 printf("CSI%d;%d\"p unknown\n", ARG(0), ARG(1));
282 case A2('"', 'q'): /* DECSCA select character attribute VT300 */
285 case 1: /* erasable */
287 case 2: /* not erasable */
288 #ifdef VT100_PRINTNOTIMPL
289 printf("CSI2\"q ignored\n");
293 #ifdef VT100_PRINTUNKNOWN
294 printf("CSI%d\"q unknown\n", ARG(0));
300 case A2('$', 'u'): /* DECRQTSR request terminal status report */
302 case 0: /* ignored */
304 case 1: /* terminal state report */
305 #ifdef VT100_PRINTNOTIMPL
306 printf("CSI1$u ignored\n");
310 #ifdef VT100_PRINTUNKNOWN
311 printf("CSI%d$u unknown\n", ARG(0));
316 case A2('$', 'w'): /* DECRQPSR request presentation status report
321 case 1: /* cursor information report */
322 #ifdef VT100_PRINTNOTIMPL
323 printf("CSI1$w ignored\n");
326 case 2: /* tab stop report */
330 KASSERT(edp
->tabs
!= 0);
331 wsdisplay_emulinput(edp
->cbcookie
, "\033P2$u", 5);
332 for (i
= 0; i
< edp
->ncols
; i
++)
334 j
= snprintf(buf
, sizeof(buf
), "%s%d",
335 (ps
? "/" : ""), i
+ 1);
336 wsdisplay_emulinput(edp
->cbcookie
,
341 wsdisplay_emulinput(edp
->cbcookie
, "\033\\", 2);
344 #ifdef VT100_PRINTUNKNOWN
345 printf("CSI%d$w unknown\n", ARG(0));
350 case A2('$', '}'): /* DECSASD select active status display */
352 case 0: /* main display */
353 case 1: /* status line */
354 #ifdef VT100_PRINTNOTIMPL
355 printf("CSI%d$} ignored\n", ARG(0));
359 #ifdef VT100_PRINTUNKNOWN
360 printf("CSI%d$} unknown\n", ARG(0));
365 case A2('$', '~'): /* DECSSDD select status line type */
368 case 1: /* indicator */
369 case 2: /* host-writable */
370 #ifdef VT100_PRINTNOTIMPL
371 printf("CSI%d$~ ignored\n", ARG(0));
375 #ifdef VT100_PRINTUNKNOWN
376 printf("CSI%d$~ unknown\n", ARG(0));
382 case A2('&', 'u'): /* DECRQUPSS request user preferred
384 wsdisplay_emulinput(edp
->cbcookie
, "\033P0!u%5\033\\", 9);
387 case '@': /* ICH insert character VT300 only */
388 n
= min(DEF1_ARG(0), COLS_LEFT
+ 1);
389 help
= NCOLS
- (edp
->ccol
+ n
);
391 COPYCOLS(edp
->ccol
, edp
->ccol
+ n
, help
);
392 ERASECOLS(edp
->ccol
, n
, edp
->bkgdattr
);
395 edp
->crow
-= min(DEF1_ARG(0), ROWS_ABOVE
);
399 edp
->crow
+= min(DEF1_ARG(0), ROWS_BELOW
);
403 edp
->ccol
+= min(DEF1_ARG(0), COLS_LEFT
);
406 edp
->ccol
-= min(DEF1_ARG(0), edp
->ccol
);
407 edp
->flags
&= ~VTFL_LASTCHAR
;
411 if (edp
->flags
& VTFL_DECOM
)
412 edp
->crow
= edp
->scrreg_startrow
+
413 min(DEF1_ARG(0), edp
->scrreg_nrows
) - 1;
415 edp
->crow
= min(DEF1_ARG(0), edp
->nrows
) - 1;
417 edp
->ccol
= min(DEF1_ARG(1), NCOLS
) - 1;
418 edp
->flags
&= ~VTFL_LASTCHAR
;
420 case 'L': /* IL insert line */
421 case 'M': /* DL delete line */
422 n
= min(DEF1_ARG(0), ROWS_BELOW
+ 1);
424 int savscrstartrow
, savscrnrows
;
425 savscrstartrow
= edp
->scrreg_startrow
;
426 savscrnrows
= edp
->scrreg_nrows
;
427 edp
->scrreg_nrows
-= ROWS_ABOVE
;
428 edp
->scrreg_startrow
= edp
->crow
;
430 wsemul_vt100_scrolldown(edp
, n
);
432 wsemul_vt100_scrollup(edp
, n
);
433 edp
->scrreg_startrow
= savscrstartrow
;
434 edp
->scrreg_nrows
= savscrnrows
;
437 case 'P': /* DCH delete character */
438 n
= min(DEF1_ARG(0), COLS_LEFT
+ 1);
439 help
= NCOLS
- (edp
->ccol
+ n
);
441 COPYCOLS(edp
->ccol
+ n
, edp
->ccol
, help
);
442 ERASECOLS(NCOLS
- n
, n
, edp
->bkgdattr
);
444 case 'X': /* ECH erase character */
445 n
= min(DEF1_ARG(0), COLS_LEFT
+ 1);
446 ERASECOLS(edp
->ccol
, n
, edp
->bkgdattr
);
448 case 'c': /* DA primary */
450 wsdisplay_emulinput(edp
->cbcookie
, WSEMUL_VT_ID1
,
451 sizeof(WSEMUL_VT_ID1
));
454 KASSERT(edp
->tabs
!= 0);
457 edp
->tabs
[edp
->ccol
] = 0;
460 memset(edp
->tabs
, 0, edp
->ncols
);
463 #ifdef VT100_PRINTUNKNOWN
464 printf("CSI%dg unknown\n", ARG(0));
469 case 'm': /* SGR select graphic rendition */
470 flags
= edp
->attrflags
;
473 for (n
= 0; n
< edp
->nargs
; n
++) {
476 if (n
== edp
->nargs
- 1) {
477 edp
->bkgdattr
= edp
->curattr
= edp
->defattr
;
478 edp
->attrflags
= edp
->msgattrs
.default_attrs
;
479 edp
->fgcol
= edp
->msgattrs
.default_fg
;
480 edp
->bgcol
= edp
->msgattrs
.default_bg
;
483 flags
= edp
->msgattrs
.default_attrs
;
484 fgcol
= edp
->msgattrs
.default_fg
;
485 bgcol
= edp
->msgattrs
.default_bg
;
488 flags
|= WSATTR_HILIT
;
490 case 4: /* underline */
491 flags
|= WSATTR_UNDERLINE
;
494 flags
|= WSATTR_BLINK
;
496 case 7: /* reverse */
497 flags
|= WSATTR_REVERSE
;
499 case 22: /* ~bold VT300 only */
500 flags
&= ~WSATTR_HILIT
;
502 case 24: /* ~underline VT300 only */
503 flags
&= ~WSATTR_UNDERLINE
;
505 case 25: /* ~blink VT300 only */
506 flags
&= ~WSATTR_BLINK
;
508 case 27: /* ~reverse VT300 only */
509 flags
&= ~WSATTR_REVERSE
;
511 case 30: case 31: case 32: case 33:
512 case 34: case 35: case 36: case 37:
514 flags
|= WSATTR_WSCOLORS
;
517 case 40: case 41: case 42: case 43:
518 case 44: case 45: case 46: case 47:
520 flags
|= WSATTR_WSCOLORS
;
524 #ifdef VT100_PRINTUNKNOWN
525 printf("CSI%dm unknown\n", ARG(n
));
530 if (vt100_selectattribute(edp
, flags
, fgcol
, bgcol
, &attr
,
533 printf("error allocating attr %d/%d/%x\n",
534 fgcol
, bgcol
, flags
);
538 edp
->bkgdattr
= bkgdattr
;
539 edp
->attrflags
= flags
;
544 case 'n': /* reports */
546 case 5: /* DSR operating status */
547 /* 0 = OK, 3 = malfunction */
548 wsdisplay_emulinput(edp
->cbcookie
, "\033[0n", 4);
550 case 6: { /* DSR cursor position report */
553 if (edp
->flags
& VTFL_DECOM
)
557 n
= snprintf(buf
, sizeof(buf
), "\033[%d;%dR",
558 row
+ 1, edp
->ccol
+ 1);
559 wsdisplay_emulinput(edp
->cbcookie
, buf
, n
);
562 case 15: /* DSR printer status */
563 /* 13 = no printer, 10 = ready, 11 = not ready */
564 wsdisplay_emulinput(edp
->cbcookie
, "\033[?13n", 6);
566 case 25: /* UDK status - VT300 only */
567 /* 20 = locked, 21 = unlocked */
568 wsdisplay_emulinput(edp
->cbcookie
, "\033[?21n", 6);
570 case 26: /* keyboard dialect */
571 /* 1 = north american , 7 = german */
572 wsdisplay_emulinput(edp
->cbcookie
, "\033[?27;1n", 8);
575 #ifdef VT100_PRINTUNKNOWN
576 printf("CSI%dn unknown\n", ARG(0));
581 case 'r': /* DECSTBM set top/bottom margins */
582 help
= min(DEF1_ARG(0), edp
->nrows
) - 1;
583 n
= min(DEFx_ARG(1, edp
->nrows
), edp
->nrows
) - help
;
585 /* minimal scrolling region has 2 lines */
588 edp
->scrreg_startrow
= help
;
589 edp
->scrreg_nrows
= n
;
591 edp
->crow
= ((edp
->flags
& VTFL_DECOM
) ?
592 edp
->scrreg_startrow
: 0);
597 case 4: /* DECTST invoke confidence test */
601 #ifdef VT100_PRINTUNKNOWN
602 printf("CSI%dy unknown\n", ARG(0));
608 #ifdef VT100_PRINTUNKNOWN
609 printf("CSI%c (%d, %d) unknown\n", c
, ARG(0), ARG(1));
616 * get an attribute from the graphics driver,
617 * try to find replacements if the desired appearance
621 vt100_selectattribute(struct wsemul_vt100_emuldata
*edp
,
622 int flags
, int fgcol
, int bgcol
, long *attr
, long *bkgdattr
)
626 if (!(edp
->scrcapabilities
& WSSCREEN_WSCOLORS
)) {
627 flags
&= ~WSATTR_WSCOLORS
;
629 printf("colors ignored (impossible)\n");
632 flags
|= WSATTR_WSCOLORS
;
633 error
= (*edp
->emulops
->allocattr
)(edp
->emulcookie
, fgcol
, bgcol
,
634 flags
& WSATTR_WSCOLORS
, bkgdattr
);
638 if ((flags
& WSATTR_HILIT
) &&
639 !(edp
->scrcapabilities
& WSSCREEN_HILIT
)) {
640 flags
&= ~WSATTR_HILIT
;
641 if (edp
->scrcapabilities
& WSSCREEN_WSCOLORS
) {
642 #if defined(WSEMUL_VT100_HILIT_FG) && WSEMUL_VT100_HILIT_FG != -1
643 fgcol
= WSEMUL_VT100_HILIT_FG
;
644 #elif !defined(WSEMUL_VT100_HILIT_FG)
647 #if defined(WSEMUL_VT100_HILIT_BG) && WSEMUL_VT100_HILIT_BG != -1
648 bgcol
= WSEMUL_VT100_HILIT_BG
;
650 flags
|= WSATTR_WSCOLORS
;
653 printf("bold ignored (impossible)\n");
657 if ((flags
& WSATTR_UNDERLINE
) &&
658 !(edp
->scrcapabilities
& WSSCREEN_UNDERLINE
)) {
659 flags
&= ~WSATTR_UNDERLINE
;
660 if (edp
->scrcapabilities
& WSSCREEN_WSCOLORS
) {
661 #if defined(WSEMUL_VT100_UNDERLINE_FG) && WSEMUL_VT100_UNDERLINE_FG != -1
662 fgcol
= WSEMUL_VT100_UNDERLINE_FG
;
664 #if defined(WSEMUL_VT100_UNDERLINE_BG) && WSEMUL_VT100_UNDERLINE_BG != -1
665 bgcol
= WSEMUL_VT100_UNDERLINE_BG
;
666 #elif !defined(WSEMUL_VT100_UNDERLINE_BG)
669 flags
|= WSATTR_WSCOLORS
;
672 printf("underline ignored (impossible)\n");
676 if ((flags
& WSATTR_BLINK
) &&
677 !(edp
->scrcapabilities
& WSSCREEN_BLINK
)) {
678 flags
&= ~WSATTR_BLINK
;
680 printf("blink ignored (impossible)\n");
683 if ((flags
& WSATTR_REVERSE
) &&
684 !(edp
->scrcapabilities
& WSSCREEN_REVERSE
)) {
685 flags
&= ~WSATTR_REVERSE
;
686 if (edp
->scrcapabilities
& WSSCREEN_WSCOLORS
) {
691 flags
|= WSATTR_WSCOLORS
;
694 printf("reverse ignored (impossible)\n");
698 error
= (*edp
->emulops
->allocattr
)(edp
->emulcookie
, fgcol
, bgcol
,
707 * handle device control sequences if the main state machine
708 * told so by setting edp->dcstype to a nonzero value
711 wsemul_vt100_handle_dcs(struct wsemul_vt100_emuldata
*edp
)
715 switch (edp
->dcstype
) {
716 case 0: /* not handled */
718 case DCSTYPE_TABRESTORE
:
719 KASSERT(edp
->tabs
!= 0);
720 memset(edp
->tabs
, 0, edp
->ncols
);
722 for (i
= 0; i
< edp
->dcspos
; i
++) {
723 char c
= edp
->dcsarg
[i
];
725 case '0': case '1': case '2': case '3': case '4':
726 case '5': case '6': case '7': case '8': case '9':
727 pos
= pos
* 10 + (edp
->dcsarg
[i
] - '0');
731 edp
->tabs
[pos
- 1] = 1;
735 #ifdef VT100_PRINTUNKNOWN
736 printf("unknown char %c in DCS\n", c
);
742 edp
->tabs
[pos
- 1] = 1;
745 panic("wsemul_vt100_handle_dcs: bad type %d", edp
->dcstype
);
751 vt100_ansimode(struct wsemul_vt100_emuldata
*edp
, int nr
, int op
)
753 int res
= 0; /* default: unknown */
756 case 2: /* KAM keyboard locked/unlocked */
758 case 3: /* CRM control representation */
760 case 4: /* IRM insert/replace characters */
761 if (op
== VTMODE_SET
)
762 edp
->flags
|= VTFL_INSERTMODE
;
763 else if (op
== VTMODE_RESET
)
764 edp
->flags
&= ~VTFL_INSERTMODE
;
765 res
= ((edp
->flags
& VTFL_INSERTMODE
) ? 1 : 2);
767 case 10: /* HEM horizontal editing (permanently reset) */
770 case 12: /* SRM local echo off/on */
771 res
= 4; /* permanently reset ??? */
773 case 20: /* LNM newline = newline/linefeed */
776 #ifdef VT100_PRINTUNKNOWN
777 printf("ANSI mode %d unknown\n", nr
);
785 vt100_decmode(struct wsemul_vt100_emuldata
*edp
, int nr
, int op
)
787 int res
= 0; /* default: unknown */
792 case 1: /* DECCKM application/nomal cursor keys */
793 if (op
== VTMODE_SET
)
794 flags
|= VTFL_APPLCURSOR
;
795 else if (op
== VTMODE_RESET
)
796 flags
&= ~VTFL_APPLCURSOR
;
797 res
= ((flags
& VTFL_APPLCURSOR
) ? 1 : 2);
799 case 2: /* DECANM ANSI vt100/vt52 */
800 res
= 3; /* permanently set ??? */
802 case 3: /* DECCOLM 132/80 cols */
803 case 4: /* DECSCLM smooth/jump scroll */
804 case 5: /* DECSCNM light/dark background */
805 res
= 4; /* all permanently reset ??? */
807 case 6: /* DECOM move within/outside margins */
808 if (op
== VTMODE_SET
)
810 else if (op
== VTMODE_RESET
)
811 flags
&= ~VTFL_DECOM
;
812 res
= ((flags
& VTFL_DECOM
) ? 1 : 2);
814 case 7: /* DECAWM autowrap */
815 if (op
== VTMODE_SET
)
816 flags
|= VTFL_DECAWM
;
817 else if (op
== VTMODE_RESET
)
818 flags
&= ~VTFL_DECAWM
;
819 res
= ((flags
& VTFL_DECAWM
) ? 1 : 2);
821 case 8: /* DECARM keyboard autorepeat */
823 case 18: /* DECPFF print form feed */
825 case 19: /* DECPEX printer extent: screen/scrolling region */
827 case 25: /* DECTCEM text cursor on/off */
828 if (op
== VTMODE_SET
)
829 flags
|= VTFL_CURSORON
;
830 else if (op
== VTMODE_RESET
)
831 flags
&= ~VTFL_CURSORON
;
832 if (flags
!= edp
->flags
)
833 (*edp
->emulops
->cursor
)(edp
->emulcookie
,
834 flags
& VTFL_CURSORON
,
835 edp
->crow
, edp
->ccol
);
836 res
= ((flags
& VTFL_CURSORON
) ? 1 : 2);
838 case 42: /* DECNRCM use 7-bit NRC /
839 7/8 bit from DEC multilingual or ISO-latin-1*/
840 if (op
== VTMODE_SET
)
841 flags
|= VTFL_NATCHARSET
;
842 else if (op
== VTMODE_RESET
)
843 flags
&= ~VTFL_NATCHARSET
;
844 res
= ((flags
& VTFL_NATCHARSET
) ? 1 : 2);
846 case 66: /* DECNKM numeric keypad */
848 case 68: /* DECKBUM keyboard usage data processing/typewriter */
851 #ifdef VT100_PRINTUNKNOWN
852 printf("DEC mode %d unknown\n", nr
);