Home | History | Annotate | Line # | Download | only in wscons
wsemul_vt100_subr.c revision 1.8.2.1
      1  1.8.2.1   nathanw /* $NetBSD: wsemul_vt100_subr.c,v 1.8.2.1 2001/10/22 20:41:48 nathanw 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 
     38      1.1  drochner #include <dev/wscons/wsksymvar.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 
     43  1.8.2.1   nathanw static int vt100_selectattribute(struct wsemul_vt100_emuldata *,
     44  1.8.2.1   nathanw 				      int, int, int, long *, long *);
     45  1.8.2.1   nathanw static int vt100_ansimode(struct wsemul_vt100_emuldata *, int, int);
     46  1.8.2.1   nathanw static int vt100_decmode(struct wsemul_vt100_emuldata *, int, int);
     47      1.2  drochner #define VTMODE_SET 33
     48      1.2  drochner #define VTMODE_RESET 44
     49      1.2  drochner #define VTMODE_REPORT 55
     50      1.1  drochner 
     51      1.1  drochner /*
     52      1.1  drochner  * scroll up within scrolling region
     53      1.1  drochner  */
     54      1.1  drochner void
     55  1.8.2.1   nathanw wsemul_vt100_scrollup(struct wsemul_vt100_emuldata *edp, int n)
     56      1.1  drochner {
     57      1.1  drochner 	int help;
     58      1.1  drochner 
     59      1.1  drochner 	if (n > edp->scrreg_nrows)
     60      1.1  drochner 		n = edp->scrreg_nrows;
     61      1.1  drochner 
     62      1.1  drochner 	help = edp->scrreg_nrows - n;
     63      1.2  drochner 	if (help > 0) {
     64      1.1  drochner 		(*edp->emulops->copyrows)(edp->emulcookie,
     65      1.1  drochner 					  edp->scrreg_startrow + n,
     66      1.1  drochner 					  edp->scrreg_startrow,
     67      1.1  drochner 					  help);
     68      1.2  drochner 		if (edp->dblwid)
     69      1.5  augustss 			memmove(&edp->dblwid[edp->scrreg_startrow],
     70      1.5  augustss 				&edp->dblwid[edp->scrreg_startrow + n],
     71      1.5  augustss 				help);
     72      1.2  drochner 	}
     73      1.1  drochner 	(*edp->emulops->eraserows)(edp->emulcookie,
     74      1.1  drochner 				   edp->scrreg_startrow + help, n,
     75      1.7   mycroft 				   edp->bkgdattr);
     76      1.2  drochner 	if (edp->dblwid)
     77      1.5  augustss 		memset(&edp->dblwid[edp->scrreg_startrow + help], 0, n);
     78      1.2  drochner 	CHECK_DW;
     79      1.1  drochner }
     80      1.1  drochner 
     81      1.1  drochner /*
     82      1.1  drochner  * scroll down within scrolling region
     83      1.1  drochner  */
     84      1.1  drochner void
     85  1.8.2.1   nathanw wsemul_vt100_scrolldown(struct wsemul_vt100_emuldata *edp, int n)
     86      1.1  drochner {
     87      1.1  drochner 	int help;
     88      1.1  drochner 
     89      1.1  drochner 	if (n > edp->scrreg_nrows)
     90      1.1  drochner 		n = edp->scrreg_nrows;
     91      1.1  drochner 
     92      1.1  drochner 	help = edp->scrreg_nrows - n;
     93      1.2  drochner 	if (help > 0) {
     94      1.1  drochner 		(*edp->emulops->copyrows)(edp->emulcookie,
     95      1.1  drochner 					  edp->scrreg_startrow,
     96      1.1  drochner 					  edp->scrreg_startrow + n,
     97      1.1  drochner 					  help);
     98      1.2  drochner 		if (edp->dblwid)
     99      1.5  augustss 			memmove(&edp->dblwid[edp->scrreg_startrow + n],
    100      1.5  augustss 				&edp->dblwid[edp->scrreg_startrow],
    101      1.5  augustss 				help);
    102      1.2  drochner 	}
    103      1.1  drochner 	(*edp->emulops->eraserows)(edp->emulcookie,
    104      1.1  drochner 				   edp->scrreg_startrow, n,
    105      1.7   mycroft 				   edp->bkgdattr);
    106      1.2  drochner 	if (edp->dblwid)
    107      1.5  augustss 		memset(&edp->dblwid[edp->scrreg_startrow], 0, n);
    108      1.2  drochner 	CHECK_DW;
    109      1.1  drochner }
    110      1.1  drochner 
    111      1.1  drochner /*
    112      1.1  drochner  * erase in display
    113      1.1  drochner  */
    114      1.1  drochner void
    115  1.8.2.1   nathanw wsemul_vt100_ed(struct wsemul_vt100_emuldata *edp, int arg)
    116      1.1  drochner {
    117      1.1  drochner 	int n;
    118      1.1  drochner 
    119      1.1  drochner 	switch (arg) {
    120      1.1  drochner 	    case 0: /* cursor to end */
    121      1.7   mycroft 		ERASECOLS(edp->ccol, COLS_LEFT + 1, edp->bkgdattr);
    122      1.1  drochner 		n = edp->nrows - edp->crow - 1;
    123      1.1  drochner 		if (n > 0) {
    124      1.1  drochner 			(*edp->emulops->eraserows)(edp->emulcookie,
    125      1.1  drochner 						   edp->crow + 1, n,
    126      1.7   mycroft 						   edp->bkgdattr);
    127      1.2  drochner 			if (edp->dblwid)
    128      1.5  augustss 				memset(&edp->dblwid[edp->crow + 1], 0, n);
    129      1.1  drochner 		}
    130      1.1  drochner 		break;
    131      1.1  drochner 	    case 1: /* beginning to cursor */
    132      1.1  drochner 		if (edp->crow > 0) {
    133      1.1  drochner 			(*edp->emulops->eraserows)(edp->emulcookie,
    134      1.1  drochner 						   0, edp->crow,
    135      1.7   mycroft 						   edp->bkgdattr);
    136      1.2  drochner 			if (edp->dblwid)
    137      1.5  augustss 				memset(&edp->dblwid[0], 0, edp->crow);
    138      1.1  drochner 		}
    139      1.7   mycroft 		ERASECOLS(0, edp->ccol + 1, edp->bkgdattr);
    140      1.1  drochner 		break;
    141      1.1  drochner 	    case 2: /* complete display */
    142      1.1  drochner 		(*edp->emulops->eraserows)(edp->emulcookie,
    143      1.1  drochner 					   0, edp->nrows,
    144      1.7   mycroft 					   edp->bkgdattr);
    145      1.2  drochner 		if (edp->dblwid)
    146      1.5  augustss 			memset(&edp->dblwid[0], 0, edp->nrows);
    147      1.1  drochner 		break;
    148      1.1  drochner 	    default:
    149      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    150      1.1  drochner 		printf("ed(%d) unknown\n", arg);
    151      1.1  drochner #endif
    152      1.1  drochner 		break;
    153      1.1  drochner 	}
    154      1.2  drochner 	CHECK_DW;
    155      1.1  drochner }
    156      1.1  drochner 
    157      1.1  drochner /*
    158      1.1  drochner  * erase in line
    159      1.1  drochner  */
    160      1.1  drochner void
    161  1.8.2.1   nathanw wsemul_vt100_el(struct wsemul_vt100_emuldata *edp, int arg)
    162      1.1  drochner {
    163      1.1  drochner 	switch (arg) {
    164      1.1  drochner 	    case 0: /* cursor to end */
    165      1.7   mycroft 		ERASECOLS(edp->ccol, COLS_LEFT + 1, edp->bkgdattr);
    166      1.1  drochner 		break;
    167      1.1  drochner 	    case 1: /* beginning to cursor */
    168      1.7   mycroft 		ERASECOLS(0, edp->ccol + 1, edp->bkgdattr);
    169      1.1  drochner 		break;
    170      1.1  drochner 	    case 2: /* complete line */
    171      1.1  drochner 		(*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
    172      1.1  drochner 					   0, edp->ncols,
    173      1.7   mycroft 					   edp->bkgdattr);
    174      1.1  drochner 		break;
    175      1.1  drochner 	    default:
    176      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    177      1.1  drochner 		printf("el(%d) unknown\n", arg);
    178      1.1  drochner #endif
    179      1.1  drochner 		break;
    180      1.1  drochner 	}
    181      1.1  drochner }
    182      1.1  drochner 
    183      1.1  drochner /*
    184      1.1  drochner  * handle commands after CSI (ESC[)
    185      1.1  drochner  */
    186      1.1  drochner void
    187  1.8.2.1   nathanw wsemul_vt100_handle_csi(struct wsemul_vt100_emuldata *edp, u_char c)
    188      1.1  drochner {
    189      1.1  drochner 	int n, help, flags, fgcol, bgcol;
    190      1.7   mycroft 	long attr, bkgdattr;
    191      1.1  drochner 
    192      1.2  drochner #define A3(a, b, c) (((a) << 16) | ((b) << 8) | (c))
    193      1.2  drochner 	switch (A3(edp->modif1, edp->modif2, c)) {
    194      1.2  drochner 	    case A3('>', '\0', 'c'): /* DA secondary */
    195      1.2  drochner 		wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID2,
    196      1.2  drochner 				    sizeof(WSEMUL_VT_ID2));
    197      1.2  drochner 		break;
    198      1.2  drochner 
    199      1.2  drochner 	    case A3('\0', '\0', 'J'): /* ED selective erase in display */
    200      1.2  drochner 	    case A3('?', '\0', 'J'): /* DECSED selective erase in display */
    201      1.2  drochner 		wsemul_vt100_ed(edp, ARG(0));
    202      1.2  drochner 		break;
    203      1.2  drochner 	    case A3('\0', '\0', 'K'): /* EL selective erase in line */
    204      1.2  drochner 	    case A3('?', '\0', 'K'): /* DECSEL selective erase in line */
    205      1.2  drochner 		wsemul_vt100_el(edp, ARG(0));
    206      1.2  drochner 		break;
    207      1.2  drochner 	    case A3('\0', '\0', 'h'): /* SM */
    208      1.2  drochner 		for (n = 0; n < edp->nargs; n++)
    209      1.2  drochner 			vt100_ansimode(edp, ARG(n), VTMODE_SET);
    210      1.2  drochner 		break;
    211      1.2  drochner 	    case A3('?', '\0', 'h'): /* DECSM */
    212      1.2  drochner 		for (n = 0; n < edp->nargs; n++)
    213      1.2  drochner 			vt100_decmode(edp, ARG(n), VTMODE_SET);
    214      1.2  drochner 		break;
    215      1.2  drochner 	    case A3('\0', '\0', 'l'): /* RM */
    216      1.2  drochner 		for (n = 0; n < edp->nargs; n++)
    217      1.2  drochner 			vt100_ansimode(edp, ARG(n), VTMODE_RESET);
    218      1.2  drochner 		break;;
    219      1.2  drochner 	    case A3('?', '\0', 'l'): /* DECRM */
    220      1.2  drochner 		for (n = 0; n < edp->nargs; n++)
    221      1.2  drochner 			vt100_decmode(edp, ARG(n), VTMODE_RESET);
    222      1.2  drochner 		break;;
    223      1.2  drochner 	    case A3('\0', '$', 'p'): /* DECRQM request mode ANSI */
    224      1.2  drochner 		vt100_ansimode(edp, ARG(0), VTMODE_REPORT);
    225      1.2  drochner 		break;
    226      1.2  drochner 	    case A3('?', '$', 'p'): /* DECRQM request mode DEC */
    227      1.2  drochner 		vt100_decmode(edp, ARG(0), VTMODE_REPORT);
    228      1.2  drochner 		break;
    229      1.2  drochner 	    case A3('\0', '\0', 'i'): /* MC printer controller mode */
    230      1.2  drochner 	    case A3('?', '\0', 'i'): /* MC printer controller mode */
    231      1.2  drochner 		switch (ARG(0)) {
    232      1.2  drochner 		    case 0: /* print screen */
    233      1.2  drochner 		    case 1: /* print cursor line */
    234      1.2  drochner 		    case 4: /* off */
    235      1.2  drochner 		    case 5: /* on */
    236      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    237      1.2  drochner 			printf("CSI%di ignored\n", ARG(0));
    238      1.2  drochner #endif
    239      1.2  drochner 			break;
    240      1.2  drochner 		    default:
    241      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    242      1.2  drochner 			printf("CSI%di unknown\n", ARG(0));
    243      1.2  drochner #endif
    244      1.2  drochner 			break;
    245      1.2  drochner 		}
    246      1.2  drochner 		break;
    247      1.2  drochner 
    248      1.2  drochner #define A2(a, b) (((a) << 8) | (b))
    249      1.2  drochner 	    case A2('!', 'p'): /* DECSTR soft reset VT300 only */
    250      1.2  drochner 		wsemul_vt100_reset(edp);
    251      1.2  drochner 		break;
    252      1.2  drochner 
    253      1.2  drochner 	    case A2('"', 'p'): /* DECSCL */
    254      1.2  drochner 		switch (ARG(0)) {
    255      1.2  drochner 		    case 61: /* VT100 mode (no further arguments!) */
    256      1.2  drochner 			break;
    257      1.2  drochner 		    case 62:
    258      1.2  drochner 		    case 63: /* VT300 mode */
    259      1.2  drochner 			break;
    260      1.2  drochner 		    default:
    261      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    262      1.2  drochner 			printf("CSI%d\"p unknown\n", ARG(0));
    263      1.2  drochner #endif
    264      1.2  drochner 			break;
    265      1.2  drochner 		}
    266      1.2  drochner 		switch (ARG(1)) {
    267      1.2  drochner 		    case 0:
    268      1.2  drochner 		    case 2: /* 8-bit controls */
    269      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    270      1.2  drochner 			printf("CSI%d;%d\"p ignored\n", ARG(0), ARG(1));
    271      1.2  drochner #endif
    272      1.2  drochner 			break;
    273      1.2  drochner 		    case 1: /* 7-bit controls */
    274      1.2  drochner 			break;
    275      1.2  drochner 		    default:
    276      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    277      1.2  drochner 			printf("CSI%d;%d\"p unknown\n", ARG(0), ARG(1));
    278      1.2  drochner #endif
    279      1.2  drochner 			break;
    280      1.2  drochner 		}
    281      1.2  drochner 		break;
    282      1.2  drochner 	    case A2('"', 'q'): /* DECSCA select character attribute VT300 */
    283      1.2  drochner 		switch (ARG(0)) {
    284      1.2  drochner 		    case 0:
    285      1.2  drochner 		    case 1: /* erasable */
    286      1.2  drochner 			break;
    287      1.2  drochner 		    case 2: /* not erasable */
    288      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    289      1.2  drochner 			printf("CSI2\"q ignored\n");
    290      1.2  drochner #endif
    291      1.2  drochner 			break;
    292      1.2  drochner 		    default:
    293      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    294      1.2  drochner 			printf("CSI%d\"q unknown\n", ARG(0));
    295      1.2  drochner #endif
    296      1.2  drochner 			break;
    297      1.2  drochner 		}
    298      1.2  drochner 		break;
    299      1.2  drochner 
    300      1.2  drochner 	    case A2('$', 'u'): /* DECRQTSR request terminal status report */
    301      1.2  drochner 		switch (ARG(0)) {
    302      1.2  drochner 		    case 0: /* ignored */
    303      1.2  drochner 			break;
    304      1.2  drochner 		    case 1: /* terminal state report */
    305      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    306      1.2  drochner 			printf("CSI1$u ignored\n");
    307      1.2  drochner #endif
    308      1.2  drochner 			break;
    309      1.2  drochner 		    default:
    310      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    311      1.2  drochner 			printf("CSI%d$u unknown\n", ARG(0));
    312      1.2  drochner #endif
    313      1.2  drochner 			break;
    314      1.2  drochner 		}
    315      1.2  drochner 		break;
    316      1.2  drochner 	    case A2('$', 'w'): /* DECRQPSR request presentation status report
    317      1.2  drochner 				(VT300 only) */
    318      1.2  drochner 		switch (ARG(0)) {
    319      1.2  drochner 		    case 0: /* error */
    320      1.2  drochner 			break;
    321      1.2  drochner 		    case 1: /* cursor information report */
    322      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    323      1.2  drochner 			printf("CSI1$w ignored\n");
    324      1.2  drochner #endif
    325      1.2  drochner 			break;
    326      1.2  drochner 		    case 2: /* tab stop report */
    327      1.2  drochner 			{
    328      1.3  drochner 			int i, n, ps = 0;
    329      1.2  drochner 			char buf[20];
    330      1.2  drochner 			KASSERT(edp->tabs != 0);
    331      1.2  drochner 			wsdisplay_emulinput(edp->cbcookie, "\033P2$u", 5);
    332      1.2  drochner 			for (i = 0; i < edp->ncols; i++)
    333      1.2  drochner 				if (edp->tabs[i]) {
    334      1.2  drochner 					n = sprintf(buf, "%s%d",
    335      1.3  drochner 						    (ps ? "/" : ""), i + 1);
    336      1.2  drochner 					wsdisplay_emulinput(edp->cbcookie,
    337      1.2  drochner 							    buf, n);
    338      1.3  drochner 					ps = 1;
    339      1.2  drochner 				}
    340      1.2  drochner 			}
    341      1.2  drochner 			wsdisplay_emulinput(edp->cbcookie, "\033\\", 2);
    342      1.2  drochner 			break;
    343      1.2  drochner 		    default:
    344      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    345      1.2  drochner 			printf("CSI%d$w unknown\n", ARG(0));
    346      1.2  drochner #endif
    347      1.2  drochner 			break;
    348      1.2  drochner 		}
    349      1.2  drochner 		break;
    350      1.2  drochner 	    case A2('$', '}'): /* DECSASD select active status display */
    351      1.2  drochner 		switch (ARG(0)) {
    352      1.2  drochner 		    case 0: /* main display */
    353      1.2  drochner 		    case 1: /* status line */
    354      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    355      1.2  drochner 			printf("CSI%d$} ignored\n", ARG(0));
    356      1.2  drochner #endif
    357      1.2  drochner 			break;
    358      1.2  drochner 		    default:
    359      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    360      1.2  drochner 			printf("CSI%d$} unknown\n", ARG(0));
    361      1.2  drochner #endif
    362      1.2  drochner 			break;
    363      1.2  drochner 		}
    364      1.2  drochner 		break;
    365      1.2  drochner 	    case A2('$', '~'): /* DECSSDD select status line type */
    366      1.2  drochner 		switch (ARG(0)) {
    367      1.2  drochner 		    case 0: /* none */
    368      1.2  drochner 		    case 1: /* indicator */
    369      1.2  drochner 		    case 2: /* host-writable */
    370      1.2  drochner #ifdef VT100_PRINTNOTIMPL
    371      1.2  drochner 			printf("CSI%d$~ ignored\n", ARG(0));
    372      1.2  drochner #endif
    373      1.2  drochner 			break;
    374      1.2  drochner 		    default:
    375      1.2  drochner #ifdef VT100_PRINTUNKNOWN
    376      1.2  drochner 			printf("CSI%d$~ unknown\n", ARG(0));
    377      1.2  drochner #endif
    378      1.2  drochner 			break;
    379      1.2  drochner 		}
    380      1.2  drochner 		break;
    381      1.2  drochner 
    382      1.2  drochner 	    case A2('&', 'u'): /* DECRQUPSS request user preferred
    383      1.2  drochner 				  supplemental set */
    384      1.2  drochner 		wsdisplay_emulinput(edp->emulcookie, "\033P0!u%5\033\\", 9);
    385      1.2  drochner 		break;
    386      1.2  drochner 
    387      1.1  drochner 	    case '@': /* ICH insert character VT300 only */
    388      1.1  drochner 		n = min(DEF1_ARG(0), COLS_LEFT + 1);
    389      1.2  drochner 		help = NCOLS - (edp->ccol + n);
    390      1.1  drochner 		if (help > 0)
    391      1.2  drochner 			COPYCOLS(edp->ccol, edp->ccol + n, help);
    392      1.7   mycroft 		ERASECOLS(edp->ccol, n, edp->bkgdattr);
    393      1.1  drochner 		break;
    394      1.1  drochner 	    case 'A': /* CUU */
    395      1.1  drochner 		edp->crow -= min(DEF1_ARG(0), ROWS_ABOVE);
    396      1.2  drochner 		CHECK_DW;
    397      1.1  drochner 		break;
    398      1.1  drochner 	    case 'B': /* CUD */
    399      1.1  drochner 		edp->crow += min(DEF1_ARG(0), ROWS_BELOW);
    400      1.2  drochner 		CHECK_DW;
    401      1.1  drochner 		break;
    402      1.1  drochner 	    case 'C': /* CUF */
    403      1.1  drochner 		edp->ccol += min(DEF1_ARG(0), COLS_LEFT);
    404      1.1  drochner 		break;
    405      1.1  drochner 	    case 'D': /* CUB */
    406      1.1  drochner 		edp->ccol -= min(DEF1_ARG(0), edp->ccol);
    407      1.1  drochner 		edp->flags &= ~VTFL_LASTCHAR;
    408      1.1  drochner 		break;
    409      1.1  drochner 	    case 'H': /* CUP */
    410      1.1  drochner 	    case 'f': /* HVP */
    411      1.1  drochner 		if (edp->flags & VTFL_DECOM)
    412      1.1  drochner 			edp->crow = edp->scrreg_startrow +
    413      1.1  drochner 			    min(DEF1_ARG(0), edp->scrreg_nrows) - 1;
    414      1.1  drochner 		else
    415      1.1  drochner 			edp->crow = min(DEF1_ARG(0), edp->nrows) - 1;
    416      1.2  drochner 		CHECK_DW;
    417      1.2  drochner 		edp->ccol = min(DEF1_ARG(1), NCOLS) - 1;
    418      1.1  drochner 		edp->flags &= ~VTFL_LASTCHAR;
    419      1.1  drochner 		break;
    420      1.1  drochner 	    case 'L': /* IL insert line */
    421      1.1  drochner 	    case 'M': /* DL delete line */
    422      1.1  drochner 		n = min(DEF1_ARG(0), ROWS_BELOW + 1);
    423      1.1  drochner 		{
    424      1.2  drochner 		int savscrstartrow, savscrnrows;
    425      1.2  drochner 		savscrstartrow = edp->scrreg_startrow;
    426      1.2  drochner 		savscrnrows = edp->scrreg_nrows;
    427      1.2  drochner 		edp->scrreg_nrows -= ROWS_ABOVE;
    428      1.2  drochner 		edp->scrreg_startrow = edp->crow;
    429      1.2  drochner 		if (c == 'L')
    430      1.2  drochner 			wsemul_vt100_scrolldown(edp, n);
    431      1.2  drochner 		else
    432      1.2  drochner 			wsemul_vt100_scrollup(edp, n);
    433      1.2  drochner 		edp->scrreg_startrow = savscrstartrow;
    434      1.2  drochner 		edp->scrreg_nrows = savscrnrows;
    435      1.1  drochner 		}
    436      1.1  drochner 		break;
    437      1.1  drochner 	    case 'P': /* DCH delete character */
    438      1.1  drochner 		n = min(DEF1_ARG(0), COLS_LEFT + 1);
    439      1.2  drochner 		help = NCOLS - (edp->ccol + n);
    440      1.1  drochner 		if (help > 0)
    441      1.2  drochner 			COPYCOLS(edp->ccol + n, edp->ccol, help);
    442      1.7   mycroft 		ERASECOLS(NCOLS - n, n, edp->bkgdattr);
    443      1.1  drochner 		break;
    444      1.1  drochner 	    case 'X': /* ECH erase character */
    445      1.1  drochner 		n = min(DEF1_ARG(0), COLS_LEFT + 1);
    446      1.7   mycroft 		ERASECOLS(edp->ccol, n, edp->bkgdattr);
    447      1.1  drochner 		break;
    448      1.1  drochner 	    case 'c': /* DA primary */
    449      1.1  drochner 		if (ARG(0) == 0)
    450      1.1  drochner 			wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID1,
    451      1.1  drochner 					    sizeof(WSEMUL_VT_ID1));
    452      1.1  drochner 		break;
    453      1.1  drochner 	    case 'g': /* TBC */
    454      1.1  drochner 		KASSERT(edp->tabs != 0);
    455      1.1  drochner 		switch (ARG(0)) {
    456      1.1  drochner 		    case 0:
    457      1.1  drochner 			edp->tabs[edp->ccol] = 0;
    458      1.1  drochner 			break;
    459      1.1  drochner 		    case 3:
    460      1.5  augustss 			memset(edp->tabs, 0, edp->ncols);
    461      1.1  drochner 			break;
    462      1.1  drochner 		    default:
    463      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    464      1.1  drochner 			printf("CSI%dg unknown\n", ARG(0));
    465      1.1  drochner #endif
    466      1.1  drochner 			break;
    467      1.1  drochner 		}
    468      1.1  drochner 		break;
    469      1.1  drochner 	    case 'm': /* SGR select graphic rendition */
    470      1.1  drochner 		flags = edp->attrflags;
    471      1.1  drochner 		fgcol = edp->fgcol;
    472      1.1  drochner 		bgcol = edp->bgcol;
    473      1.1  drochner 		for (n = 0; n < edp->nargs; n++) {
    474      1.1  drochner 			switch (ARG(n)) {
    475      1.1  drochner 			    case 0: /* reset */
    476      1.7   mycroft 				if (n == edp->nargs - 1) {
    477      1.7   mycroft 					edp->bkgdattr = edp->curattr = edp->defattr;
    478      1.7   mycroft 					edp->attrflags = 0;
    479      1.7   mycroft 					edp->fgcol = WSCOL_WHITE;
    480      1.7   mycroft 					edp->bgcol = WSCOL_BLACK;
    481      1.7   mycroft 					return;
    482      1.7   mycroft 				}
    483      1.2  drochner 				flags = 0;
    484      1.2  drochner 				fgcol = WSCOL_WHITE;
    485      1.2  drochner 				bgcol = WSCOL_BLACK;
    486      1.1  drochner 				break;
    487      1.1  drochner 			    case 1: /* bold */
    488      1.1  drochner 				flags |= WSATTR_HILIT;
    489      1.1  drochner 				break;
    490      1.1  drochner 			    case 4: /* underline */
    491      1.1  drochner 				flags |= WSATTR_UNDERLINE;
    492      1.1  drochner 				break;
    493      1.1  drochner 			    case 5: /* blink */
    494      1.1  drochner 				flags |= WSATTR_BLINK;
    495      1.1  drochner 				break;
    496      1.1  drochner 			    case 7: /* reverse */
    497      1.1  drochner 				flags |= WSATTR_REVERSE;
    498      1.1  drochner 				break;
    499      1.1  drochner 			    case 22: /* ~bold VT300 only */
    500      1.1  drochner 				flags &= ~WSATTR_HILIT;
    501      1.1  drochner 				break;
    502      1.1  drochner 			    case 24: /* ~underline VT300 only */
    503      1.1  drochner 				flags &= ~WSATTR_UNDERLINE;
    504      1.1  drochner 				break;
    505      1.1  drochner 			    case 25: /* ~blink VT300 only */
    506      1.1  drochner 				flags &= ~WSATTR_BLINK;
    507      1.1  drochner 				break;
    508      1.1  drochner 			    case 27: /* ~reverse VT300 only */
    509      1.1  drochner 				flags &= ~WSATTR_REVERSE;
    510      1.1  drochner 				break;
    511      1.1  drochner 			    case 30: case 31: case 32: case 33:
    512      1.1  drochner 			    case 34: case 35: case 36: case 37:
    513      1.1  drochner 				/* fg color */
    514      1.1  drochner 				flags |= WSATTR_WSCOLORS;
    515      1.1  drochner 				fgcol = ARG(n) - 30;
    516      1.1  drochner 				break;
    517      1.1  drochner 			    case 40: case 41: case 42: case 43:
    518      1.1  drochner 			    case 44: case 45: case 46: case 47:
    519      1.1  drochner 				/* bg color */
    520      1.1  drochner 				flags |= WSATTR_WSCOLORS;
    521      1.1  drochner 				bgcol = ARG(n) - 40;
    522      1.1  drochner 				break;
    523      1.1  drochner 			    default:
    524      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    525      1.1  drochner 				printf("CSI%dm unknown\n", ARG(n));
    526      1.1  drochner #endif
    527      1.8       cgd 				break;
    528      1.1  drochner 			}
    529      1.1  drochner 		}
    530      1.7   mycroft 		if (vt100_selectattribute(edp, flags, fgcol, bgcol, &attr,
    531      1.7   mycroft 		    &bkgdattr)) {
    532      1.1  drochner #ifdef VT100_DEBUG
    533      1.1  drochner 			printf("error allocating attr %d/%d/%x\n",
    534      1.1  drochner 			       fgcol, bgcol, flags);
    535      1.1  drochner #endif
    536      1.1  drochner 		} else {
    537      1.1  drochner 			edp->curattr = attr;
    538      1.7   mycroft 			edp->bkgdattr = bkgdattr;
    539      1.1  drochner 			edp->attrflags = flags;
    540      1.1  drochner 			edp->fgcol = fgcol;
    541      1.1  drochner 			edp->bgcol = bgcol;
    542      1.1  drochner 		}
    543      1.1  drochner 		break;
    544      1.1  drochner 	    case 'n': /* reports */
    545      1.1  drochner 		switch (ARG(0)) {
    546      1.1  drochner 		    case 5: /* DSR operating status */
    547      1.1  drochner 			/* 0 = OK, 3 = malfunction */
    548      1.1  drochner 			wsdisplay_emulinput(edp->cbcookie, "\033[0n", 4);
    549      1.1  drochner 			break;
    550      1.1  drochner 		    case 6: { /* DSR cursor position report */
    551      1.1  drochner 			char buf[20];
    552      1.1  drochner 			int row;
    553      1.1  drochner 			if (edp->flags & VTFL_DECOM)
    554      1.1  drochner 				row = ROWS_ABOVE;
    555      1.1  drochner 			else
    556      1.1  drochner 				row = edp->crow;
    557      1.1  drochner 			n = sprintf(buf, "\033[%d;%dR",
    558      1.1  drochner 				    row + 1, edp->ccol + 1);
    559      1.1  drochner 			wsdisplay_emulinput(edp->cbcookie, buf, n);
    560      1.1  drochner 			}
    561      1.1  drochner 			break;
    562      1.1  drochner 		    case 15: /* DSR printer status */
    563      1.1  drochner 			/* 13 = no printer, 10 = ready, 11 = not ready */
    564      1.1  drochner 			wsdisplay_emulinput(edp->cbcookie, "\033[?13n", 6);
    565      1.1  drochner 			break;
    566      1.1  drochner 		    case 25: /* UDK status - VT300 only */
    567      1.1  drochner 			/* 20 = locked, 21 = unlocked */
    568      1.1  drochner 			wsdisplay_emulinput(edp->cbcookie, "\033[?21n", 6);
    569      1.1  drochner 			break;
    570      1.1  drochner 		    case 26: /* keyboard dialect */
    571      1.1  drochner 			/* 1 = north american , 7 = german */
    572      1.1  drochner 			wsdisplay_emulinput(edp->cbcookie, "\033[?27;1n", 8);
    573      1.1  drochner 			break;
    574      1.1  drochner 		    default:
    575      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    576      1.1  drochner 			printf("CSI%dn unknown\n", ARG(0));
    577      1.1  drochner #endif
    578      1.1  drochner 			break;
    579      1.1  drochner 		}
    580      1.1  drochner 		break;
    581      1.1  drochner 	    case 'r': /* DECSTBM set top/bottom margins */
    582      1.4  drochner 		help = min(DEF1_ARG(0), edp->nrows) - 1;
    583      1.4  drochner 		n = min(DEFx_ARG(1, edp->nrows), edp->nrows) - help;
    584      1.4  drochner 		if (n < 2) {
    585      1.4  drochner 			/* minimal scrolling region has 2 lines */
    586      1.4  drochner 			return;
    587      1.1  drochner 		} else {
    588      1.4  drochner 			edp->scrreg_startrow = help;
    589      1.4  drochner 			edp->scrreg_nrows = n;
    590      1.1  drochner 		}
    591      1.1  drochner 		edp->crow = ((edp->flags & VTFL_DECOM) ?
    592      1.1  drochner 			     edp->scrreg_startrow : 0);
    593      1.1  drochner 		edp->ccol = 0;
    594      1.1  drochner 		break;
    595      1.1  drochner 	    case 'y':
    596      1.1  drochner 		switch (ARG(0)) {
    597      1.1  drochner 		    case 4: /* DECTST invoke confidence test */
    598      1.1  drochner 			/* ignore */
    599      1.1  drochner 			break;
    600      1.1  drochner 		    default:
    601      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    602      1.1  drochner 			printf("CSI%dy unknown\n", ARG(0));
    603      1.1  drochner #endif
    604      1.1  drochner 			break;
    605      1.1  drochner 		}
    606      1.1  drochner 		break;
    607      1.1  drochner 	    default:
    608      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    609      1.1  drochner 		printf("CSI%c (%d, %d) unknown\n", c, ARG(0), ARG(1));
    610      1.1  drochner #endif
    611      1.8       cgd 		break;
    612      1.1  drochner 	}
    613      1.1  drochner }
    614      1.1  drochner 
    615      1.1  drochner /*
    616      1.1  drochner  * get an attribute from the graphics driver,
    617      1.1  drochner  * try to find replacements if the desired appearance
    618      1.1  drochner  * is not supported
    619      1.1  drochner  */
    620      1.1  drochner static int
    621  1.8.2.1   nathanw vt100_selectattribute(struct wsemul_vt100_emuldata *edp,
    622  1.8.2.1   nathanw 	int flags, int fgcol, int bgcol, long *attr, long *bkgdattr)
    623      1.1  drochner {
    624      1.7   mycroft 	int error;
    625      1.7   mycroft 
    626      1.7   mycroft 	if ((flags & WSATTR_WSCOLORS) &&
    627      1.7   mycroft 	    !(edp->scrcapabilities & WSSCREEN_WSCOLORS)) {
    628      1.7   mycroft 		flags &= ~WSATTR_WSCOLORS;
    629      1.7   mycroft #ifdef VT100_DEBUG
    630      1.7   mycroft 		printf("colors ignored (impossible)\n");
    631      1.7   mycroft #endif
    632      1.7   mycroft 	}
    633      1.7   mycroft 	error = (*edp->emulops->alloc_attr)(edp->emulcookie, fgcol, bgcol,
    634      1.7   mycroft 					    flags & WSATTR_WSCOLORS, bkgdattr);
    635      1.7   mycroft 	if (error)
    636      1.7   mycroft 		return (error);
    637      1.7   mycroft 
    638      1.1  drochner 	if ((flags & WSATTR_HILIT) &&
    639      1.1  drochner 	    !(edp->scrcapabilities & WSSCREEN_HILIT)) {
    640      1.1  drochner 		flags &= ~WSATTR_HILIT;
    641      1.1  drochner 		if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
    642      1.1  drochner 			fgcol = WSCOL_RED;
    643      1.1  drochner 			flags |= WSATTR_WSCOLORS;
    644      1.1  drochner 		} else {
    645      1.1  drochner #ifdef VT100_DEBUG
    646      1.1  drochner 			printf("bold ignored (impossible)\n");
    647      1.1  drochner #endif
    648      1.1  drochner 		}
    649      1.1  drochner 	}
    650      1.1  drochner 	if ((flags & WSATTR_UNDERLINE) &&
    651      1.1  drochner 	    !(edp->scrcapabilities & WSSCREEN_UNDERLINE)) {
    652      1.1  drochner 		flags &= ~WSATTR_UNDERLINE;
    653      1.1  drochner 		if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
    654      1.1  drochner 			bgcol = WSCOL_BROWN;
    655      1.1  drochner 			flags &= ~WSATTR_UNDERLINE;
    656      1.1  drochner 			flags |= WSATTR_WSCOLORS;
    657      1.1  drochner 		} else {
    658      1.1  drochner #ifdef VT100_DEBUG
    659      1.1  drochner 			printf("underline ignored (impossible)\n");
    660      1.1  drochner #endif
    661      1.1  drochner 		}
    662      1.1  drochner 	}
    663      1.1  drochner 	if ((flags & WSATTR_BLINK) &&
    664      1.1  drochner 	    !(edp->scrcapabilities & WSSCREEN_BLINK)) {
    665      1.1  drochner 		flags &= ~WSATTR_BLINK;
    666      1.1  drochner #ifdef VT100_DEBUG
    667      1.1  drochner 		printf("blink ignored (impossible)\n");
    668      1.1  drochner #endif
    669      1.1  drochner 	}
    670      1.1  drochner 	if ((flags & WSATTR_REVERSE) &&
    671      1.1  drochner 	    !(edp->scrcapabilities & WSSCREEN_REVERSE)) {
    672      1.1  drochner 		flags &= ~WSATTR_REVERSE;
    673      1.1  drochner 		if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
    674      1.1  drochner 			int help;
    675      1.1  drochner 			help = bgcol;
    676      1.1  drochner 			bgcol = fgcol;
    677      1.1  drochner 			fgcol = help;
    678      1.1  drochner 			flags |= WSATTR_WSCOLORS;
    679      1.1  drochner 		} else {
    680      1.1  drochner #ifdef VT100_DEBUG
    681      1.1  drochner 			printf("reverse ignored (impossible)\n");
    682      1.1  drochner #endif
    683      1.1  drochner 		}
    684      1.1  drochner 	}
    685      1.7   mycroft 	error = (*edp->emulops->alloc_attr)(edp->emulcookie, fgcol, bgcol,
    686      1.7   mycroft 					    flags, attr);
    687      1.7   mycroft 	if (error)
    688      1.7   mycroft 		return (error);
    689      1.7   mycroft 
    690      1.7   mycroft 	return (0);
    691      1.1  drochner }
    692      1.1  drochner 
    693      1.1  drochner /*
    694      1.1  drochner  * handle device control sequences if the main state machine
    695      1.1  drochner  * told so by setting edp->dcstype to a nonzero value
    696      1.1  drochner  */
    697      1.1  drochner void
    698  1.8.2.1   nathanw wsemul_vt100_handle_dcs(struct wsemul_vt100_emuldata *edp)
    699      1.1  drochner {
    700      1.1  drochner 	int i, pos;
    701      1.1  drochner 
    702      1.1  drochner 	switch (edp->dcstype) {
    703      1.1  drochner 	    case 0: /* not handled */
    704      1.1  drochner 		return;
    705      1.1  drochner 	    case DCSTYPE_TABRESTORE:
    706      1.1  drochner 		KASSERT(edp->tabs != 0);
    707      1.5  augustss 		memset(edp->tabs, 0, edp->ncols);
    708      1.1  drochner 		pos = 0;
    709      1.1  drochner 		for (i = 0; i < edp->dcspos; i++) {
    710      1.1  drochner 			char c = edp->dcsarg[i];
    711      1.1  drochner 			switch (c) {
    712      1.1  drochner 			    case '0': case '1': case '2': case '3': case '4':
    713      1.1  drochner 			    case '5': case '6': case '7': case '8': case '9':
    714      1.1  drochner 				pos = pos * 10 + (edp->dcsarg[i] - '0');
    715      1.1  drochner 				break;
    716      1.1  drochner 			    case '/':
    717      1.1  drochner 				if (pos > 0)
    718      1.1  drochner 					edp->tabs[pos - 1] = 1;
    719      1.1  drochner 				pos = 0;
    720      1.1  drochner 				break;
    721      1.1  drochner 			    default:
    722      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    723      1.1  drochner 				printf("unknown char %c in DCS\n", c);
    724      1.1  drochner #endif
    725      1.8       cgd 				break;
    726      1.1  drochner 			}
    727      1.1  drochner 		}
    728      1.1  drochner 		if (pos > 0)
    729      1.1  drochner 			edp->tabs[pos - 1] = 1;
    730      1.1  drochner 		break;
    731      1.1  drochner 	    default:
    732      1.1  drochner 		panic("wsemul_vt100_handle_dcs: bad type %d", edp->dcstype);
    733      1.1  drochner 	}
    734      1.1  drochner 	edp->dcstype = 0;
    735      1.1  drochner }
    736      1.1  drochner 
    737      1.1  drochner static int
    738  1.8.2.1   nathanw vt100_ansimode(struct wsemul_vt100_emuldata *edp, int nr, int op)
    739      1.1  drochner {
    740      1.1  drochner 	int res = 0; /* default: unknown */
    741      1.1  drochner 
    742      1.1  drochner 	switch (nr) {
    743      1.1  drochner 	    case 2: /* KAM keyboard locked/unlocked */
    744      1.1  drochner 		break;
    745      1.1  drochner 	    case 3: /* CRM control representation */
    746      1.1  drochner 		break;
    747      1.1  drochner 	    case 4: /* IRM insert/replace characters */
    748      1.2  drochner 		if (op == VTMODE_SET)
    749      1.1  drochner 			edp->flags |= VTFL_INSERTMODE;
    750      1.2  drochner 		else if (op == VTMODE_RESET)
    751      1.1  drochner 			edp->flags &= ~VTFL_INSERTMODE;
    752      1.1  drochner 		res = ((edp->flags & VTFL_INSERTMODE) ? 1 : 2);
    753      1.1  drochner 		break;
    754      1.1  drochner 	    case 10: /* HEM horizontal editing (permanently reset) */
    755      1.1  drochner 		res = 4;
    756      1.1  drochner 		break;
    757      1.1  drochner 	    case 12: /* SRM local echo off/on */
    758      1.1  drochner 		res = 4; /* permanently reset ??? */
    759      1.1  drochner 		break;
    760      1.1  drochner 	    case 20: /* LNM newline = newline/linefeed */
    761      1.1  drochner 		break;
    762      1.1  drochner 	    default:
    763      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    764      1.1  drochner 		printf("ANSI mode %d unknown\n", nr);
    765      1.1  drochner #endif
    766      1.8       cgd 		break;
    767      1.1  drochner 	}
    768      1.1  drochner 	return (res);
    769      1.1  drochner }
    770      1.1  drochner 
    771      1.1  drochner static int
    772  1.8.2.1   nathanw vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
    773      1.1  drochner {
    774      1.1  drochner 	int res = 0; /* default: unknown */
    775      1.6   mycroft 	int flags;
    776      1.1  drochner 
    777      1.6   mycroft 	flags = edp->flags;
    778      1.1  drochner 	switch (nr) {
    779      1.1  drochner 	    case 1: /* DECCKM application/nomal cursor keys */
    780      1.2  drochner 		if (op == VTMODE_SET)
    781      1.6   mycroft 			flags |= VTFL_APPLCURSOR;
    782      1.2  drochner 		else if (op == VTMODE_RESET)
    783      1.6   mycroft 			flags &= ~VTFL_APPLCURSOR;
    784      1.6   mycroft 		res = ((flags & VTFL_APPLCURSOR) ? 1 : 2);
    785      1.1  drochner 		break;
    786      1.1  drochner 	    case 2: /* DECANM ANSI vt100/vt52 */
    787      1.1  drochner 		res = 3; /* permanently set ??? */
    788      1.1  drochner 		break;
    789      1.1  drochner 	    case 3: /* DECCOLM 132/80 cols */
    790      1.1  drochner 	    case 4: /* DECSCLM smooth/jump scroll */
    791      1.1  drochner 	    case 5: /* DECSCNM light/dark background */
    792      1.1  drochner 		res = 4; /* all permanently reset ??? */
    793      1.1  drochner 		break;
    794      1.1  drochner 	    case 6: /* DECOM move within/outside margins */
    795      1.2  drochner 		if (op == VTMODE_SET)
    796      1.6   mycroft 			flags |= VTFL_DECOM;
    797      1.2  drochner 		else if (op == VTMODE_RESET)
    798      1.6   mycroft 			flags &= ~VTFL_DECOM;
    799      1.6   mycroft 		res = ((flags & VTFL_DECOM) ? 1 : 2);
    800      1.1  drochner 		break;
    801      1.1  drochner 	    case 7: /* DECAWM autowrap */
    802      1.2  drochner 		if (op == VTMODE_SET)
    803      1.6   mycroft 			flags |= VTFL_DECAWM;
    804      1.2  drochner 		else if (op == VTMODE_RESET)
    805      1.6   mycroft 			flags &= ~VTFL_DECAWM;
    806      1.6   mycroft 		res = ((flags & VTFL_DECAWM) ? 1 : 2);
    807      1.1  drochner 		break;
    808      1.1  drochner 	    case 8: /* DECARM keyboard autorepeat */
    809      1.1  drochner 		break;
    810      1.1  drochner 	    case 18: /* DECPFF print form feed */
    811      1.1  drochner 		break;
    812      1.1  drochner 	    case 19: /* DECPEX printer extent: screen/scrolling region */
    813      1.1  drochner 		break;
    814      1.1  drochner 	    case 25: /* DECTCEM text cursor on/off */
    815      1.6   mycroft 		if (op == VTMODE_SET)
    816      1.6   mycroft 			flags |= VTFL_CURSORON;
    817      1.6   mycroft 		else if (op == VTMODE_RESET)
    818      1.6   mycroft 			flags &= ~VTFL_CURSORON;
    819      1.6   mycroft 		if (flags != edp->flags)
    820      1.1  drochner 			(*edp->emulops->cursor)(edp->emulcookie,
    821      1.6   mycroft 						flags & VTFL_CURSORON,
    822      1.1  drochner 						edp->crow, edp->ccol);
    823      1.6   mycroft 		res = ((flags & VTFL_CURSORON) ? 1 : 2);
    824      1.1  drochner 		break;
    825      1.1  drochner 	    case 42: /* DECNRCM use 7-bit NRC /
    826      1.1  drochner 		      7/8 bit from DEC multilingual or ISO-latin-1*/
    827      1.2  drochner 		if (op == VTMODE_SET)
    828      1.6   mycroft 			flags |= VTFL_NATCHARSET;
    829      1.2  drochner 		else if (op == VTMODE_RESET)
    830      1.6   mycroft 			flags &= ~VTFL_NATCHARSET;
    831      1.6   mycroft 		res = ((flags & VTFL_NATCHARSET) ? 1 : 2);
    832      1.1  drochner 		break;
    833      1.1  drochner 	    case 66: /* DECNKM numeric keypad */
    834      1.1  drochner 		break;
    835      1.1  drochner 	    case 68: /* DECKBUM keyboard usage data processing/typewriter */
    836      1.1  drochner 		break;
    837      1.1  drochner 	    default:
    838      1.1  drochner #ifdef VT100_PRINTUNKNOWN
    839      1.1  drochner 		printf("DEC mode %d unknown\n", nr);
    840      1.1  drochner #endif
    841      1.1  drochner 		break;
    842      1.1  drochner 	}
    843      1.6   mycroft 	edp->flags = flags;
    844      1.6   mycroft 
    845      1.1  drochner 	return (res);
    846      1.1  drochner }
    847