#include <sys/param.h>
#include <sys/systm.h>
#include <dev/wscons/wsconsio.h>
#include <dev/wscons/wsksymvar.h>
#include <dev/wscons/wsdisplayvar.h>
#include <dev/wscons/wsemulvar.h>
#include <dev/wscons/wsemul_vt100var.h>
int vt100_selectattribute(struct wsemul_vt100_emuldata *, int, int, int,
uint32_t *, uint32_t *);
int vt100_ansimode(struct wsemul_vt100_emuldata *, int, int);
int vt100_decmode(struct wsemul_vt100_emuldata *, int, int);
#define VTMODE_SET 33
#define VTMODE_RESET 44
#define VTMODE_REPORT 55
int
wsemul_vt100_scrollup(struct wsemul_vt100_emuldata *edp, int n)
{
int help;
int rc;
if (n > edp->scrreg_nrows)
n = edp->scrreg_nrows;
help = edp->scrreg_nrows - n;
if (help > 0) {
WSEMULOP(rc, edp, &edp->abortstate, copyrows,
(edp->emulcookie, edp->scrreg_startrow + n,
edp->scrreg_startrow, help));
if (rc != 0)
return rc;
}
WSEMULOP(rc, edp, &edp->abortstate, eraserows,
(edp->emulcookie, edp->scrreg_startrow + help, n, edp->bkgdattr));
if (rc != 0)
return rc;
#ifdef HAVE_DOUBLE_WIDTH_HEIGHT
if (edp->dblwid) {
if (help > 0)
memmove(&edp->dblwid[edp->scrreg_startrow],
&edp->dblwid[edp->scrreg_startrow + n], help);
memset(&edp->dblwid[edp->scrreg_startrow + help], 0, n);
}
CHECK_DW;
#endif
return 0;
}
int
wsemul_vt100_scrolldown(struct wsemul_vt100_emuldata *edp, int n)
{
int help;
int rc;
if (n > edp->scrreg_nrows)
n = edp->scrreg_nrows;
help = edp->scrreg_nrows - n;
if (help > 0) {
WSEMULOP(rc, edp, &edp->abortstate, copyrows,
(edp->emulcookie, edp->scrreg_startrow,
edp->scrreg_startrow + n, help));
if (rc != 0)
return rc;
}
WSEMULOP(rc, edp, &edp->abortstate, eraserows,
(edp->emulcookie, edp->scrreg_startrow, n, edp->bkgdattr));
if (rc != 0)
return rc;
#ifdef HAVE_DOUBLE_WIDTH_HEIGHT
if (edp->dblwid) {
if (help > 0)
memmove(&edp->dblwid[edp->scrreg_startrow + n],
&edp->dblwid[edp->scrreg_startrow], help);
memset(&edp->dblwid[edp->scrreg_startrow], 0, n);
}
CHECK_DW;
#endif
return 0;
}
int
wsemul_vt100_ed(struct wsemul_vt100_emuldata *edp, int arg)
{
int n;
int rc;
switch (arg) {
case 0:
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(edp->ccol, COLS_LEFT + 1, edp->bkgdattr));
if (rc != 0)
break;
n = edp->nrows - edp->crow - 1;
if (n > 0) {
WSEMULOP(rc, edp, &edp->abortstate, eraserows,
(edp->emulcookie, edp->crow + 1, n, edp->bkgdattr));
if (rc != 0)
break;
#ifdef HAVE_DOUBLE_WIDTH_HEIGHT
if (edp->dblwid)
memset(&edp->dblwid[edp->crow + 1], 0, n);
#endif
}
break;
case 1:
if (edp->crow > 0) {
WSEMULOP(rc, edp, &edp->abortstate, eraserows,
(edp->emulcookie, 0, edp->crow, edp->bkgdattr));
if (rc != 0)
break;
}
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(0, edp->ccol + 1, edp->bkgdattr));
if (rc != 0)
break;
#ifdef HAVE_DOUBLE_WIDTH_HEIGHT
if (edp->dblwid) {
if (edp->crow > 0)
memset(&edp->dblwid[0], 0, edp->crow);
}
#endif
break;
case 2:
WSEMULOP(rc, edp, &edp->abortstate, eraserows,
(edp->emulcookie, 0, edp->nrows, edp->bkgdattr));
if (rc != 0)
break;
#ifdef HAVE_DOUBLE_WIDTH_HEIGHT
if (edp->dblwid)
memset(&edp->dblwid[0], 0, edp->nrows);
#endif
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("ed(%d) unknown\n", arg);
#endif
rc = 0;
break;
}
if (rc != 0)
return rc;
CHECK_DW;
return 0;
}
int
wsemul_vt100_el(struct wsemul_vt100_emuldata *edp, int arg)
{
int rc;
switch (arg) {
case 0:
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(edp->ccol, COLS_LEFT + 1, edp->bkgdattr));
break;
case 1:
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(0, edp->ccol + 1, edp->bkgdattr));
break;
case 2:
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
(edp->emulcookie, edp->crow, 0, edp->ncols, edp->bkgdattr));
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("el(%d) unknown\n", arg);
#endif
rc = 0;
break;
}
return rc;
}
int
wsemul_vt100_handle_csi(struct wsemul_vt100_emuldata *edp,
struct wsemul_inputstate *instate, int kernel)
{
int n, m, help, flags, fgcol, bgcol;
uint32_t attr, bkgdattr;
u_char c;
int rc = 0;
if (instate->inchar >= 0x100)
c = 0x00;
else
c = (u_char)instate->inchar;
#define A3(a, b, c) (((a) << 16) | ((b) << 8) | (c))
switch (A3(edp->modif1, edp->modif2, c)) {
case A3('>', '\0', 'c'):
wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID2,
sizeof(WSEMUL_VT_ID2) - 1);
break;
case A3('\0', '\0', 'J'):
case A3('?', '\0', 'J'):
rc = wsemul_vt100_ed(edp, ARG(0));
break;
case A3('\0', '\0', 'K'):
case A3('?', '\0', 'K'):
rc = wsemul_vt100_el(edp, ARG(0));
break;
case A3('\0', '\0', 'h'):
for (n = 0; n < edp->nargs; n++)
vt100_ansimode(edp, ARG(n), VTMODE_SET);
break;
case A3('?', '\0', 'h'):
for (n = 0; n < edp->nargs; n++) {
rc = vt100_decmode(edp, ARG(n), VTMODE_SET);
if (rc != 0)
break;
}
break;
case A3('\0', '\0', 'l'):
for (n = 0; n < edp->nargs; n++)
vt100_ansimode(edp, ARG(n), VTMODE_RESET);
break;
case A3('?', '\0', 'l'):
for (n = 0; n < edp->nargs; n++) {
rc = vt100_decmode(edp, ARG(n), VTMODE_RESET);
if (rc != 0)
break;
}
break;
case A3('\0', '$', 'p'):
vt100_ansimode(edp, ARG(0), VTMODE_REPORT);
break;
case A3('?', '$', 'p'):
rc = vt100_decmode(edp, ARG(0), VTMODE_REPORT);
break;
case A3('\0', '\0', 'i'):
case A3('?', '\0', 'i'):
switch (ARG(0)) {
case 0:
case 1:
case 4:
case 5:
#ifdef VT100_PRINTNOTIMPL
printf("CSI%di ignored\n", ARG(0));
#endif
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%di unknown\n", ARG(0));
#endif
break;
}
break;
#define A2(a, b) (((a) << 8) | (b))
case A2('!', 'p'):
wsemul_vt100_reset(edp);
break;
case A2('"', 'p'):
switch (ARG(0)) {
case 61:
break;
case 62:
case 63:
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d\"p unknown\n", ARG(0));
#endif
break;
}
switch (ARG(1)) {
case 0:
case 2:
#ifdef VT100_PRINTNOTIMPL
printf("CSI%d;%d\"p ignored\n", ARG(0), ARG(1));
#endif
break;
case 1:
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d;%d\"p unknown\n", ARG(0), ARG(1));
#endif
break;
}
break;
case A2('"', 'q'):
switch (ARG(0)) {
case 0:
case 1:
break;
case 2:
#ifdef VT100_PRINTNOTIMPL
printf("CSI2\"q ignored\n");
#endif
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d\"q unknown\n", ARG(0));
#endif
break;
}
break;
case A2('$', 'u'):
switch (ARG(0)) {
case 0:
break;
case 1:
#ifdef VT100_PRINTNOTIMPL
printf("CSI1$u ignored\n");
#endif
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d$u unknown\n", ARG(0));
#endif
break;
}
break;
case A2('$', 'w'):
switch (ARG(0)) {
case 0:
break;
case 1:
#ifdef VT100_PRINTNOTIMPL
printf("CSI1$w ignored\n");
#endif
break;
case 2:
{
int i, n, ps = 0;
char buf[20];
wsdisplay_emulinput(edp->cbcookie, "\033P2$u", 5);
if (edp->tabs != NULL)
for (i = 0; i < edp->ncols; i++)
if (edp->tabs[i]) {
n = snprintf(buf, sizeof buf, "%s%d",
(ps ? "/" : ""), i + 1);
if (n == -1)
n = 0;
else if (n >= sizeof buf)
n = sizeof buf - 1;
wsdisplay_emulinput(edp->cbcookie,
buf, n);
ps = 1;
}
wsdisplay_emulinput(edp->cbcookie, "\033\\", 2);
}
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d$w unknown\n", ARG(0));
#endif
break;
}
break;
case A2('$', '}'):
switch (ARG(0)) {
case 0:
case 1:
#ifdef VT100_PRINTNOTIMPL
printf("CSI%d$} ignored\n", ARG(0));
#endif
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d$} unknown\n", ARG(0));
#endif
break;
}
break;
case A2('$', '~'):
switch (ARG(0)) {
case 0:
case 1:
case 2:
#ifdef VT100_PRINTNOTIMPL
printf("CSI%d$~ ignored\n", ARG(0));
#endif
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%d$~ unknown\n", ARG(0));
#endif
break;
}
break;
case A2('&', 'u'):
wsdisplay_emulinput(edp->cbcookie, "\033P0!u%5\033\\", 9);
break;
case '@':
n = min(DEF1_ARG(0), COLS_LEFT + 1);
help = NCOLS - (edp->ccol + n);
if (help > 0) {
WSEMULOP(rc, edp, &edp->abortstate, copycols,
COPYCOLS(edp->ccol, edp->ccol + n, help));
if (rc != 0)
break;
}
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(edp->ccol, n, edp->bkgdattr));
break;
case 'A':
n = ROWS_ABOVE;
if (n > 0)
edp->crow -= min(DEF1_ARG(0), n);
CHECK_DW;
break;
case 'B':
n = ROWS_BELOW;
if (n > 0)
edp->crow += min(DEF1_ARG(0), n);
CHECK_DW;
break;
case 'C':
edp->ccol += min(DEF1_ARG(0), COLS_LEFT);
break;
case 'D':
edp->ccol -= min(DEF1_ARG(0), edp->ccol);
edp->flags &= ~VTFL_LASTCHAR;
break;
case 'G':
case '`':
edp->ccol = min(DEF1_ARG(0), edp->ncols) - 1;
break;
case 'H':
case 'f':
if (edp->flags & VTFL_DECOM)
edp->crow = edp->scrreg_startrow +
min(DEF1_ARG(0), edp->scrreg_nrows) - 1;
else
edp->crow = min(DEF1_ARG(0), edp->nrows) - 1;
CHECK_DW;
edp->ccol = min(DEF1_ARG(1), NCOLS) - 1;
edp->flags &= ~VTFL_LASTCHAR;
break;
case 'L':
case 'M':
if (edp->crow >= edp->scrreg_startrow &&
edp->crow < edp->scrreg_startrow + edp->scrreg_nrows) {
int savscrstartrow, savscrnrows;
n = min(DEF1_ARG(0), ROWS_BELOW + 1);
savscrstartrow = edp->scrreg_startrow;
savscrnrows = edp->scrreg_nrows;
edp->scrreg_nrows -= ROWS_ABOVE;
edp->scrreg_startrow = edp->crow;
if (c == 'L')
rc = wsemul_vt100_scrolldown(edp, n);
else
rc = wsemul_vt100_scrollup(edp, n);
edp->scrreg_startrow = savscrstartrow;
edp->scrreg_nrows = savscrnrows;
}
break;
case 'P':
n = min(DEF1_ARG(0), COLS_LEFT + 1);
help = NCOLS - (edp->ccol + n);
if (help > 0) {
WSEMULOP(rc, edp, &edp->abortstate, copycols,
COPYCOLS(edp->ccol + n, edp->ccol, help));
if (rc != 0)
break;
}
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(NCOLS - n, n, edp->bkgdattr));
break;
case 'S':
wsemul_vt100_scrollup(edp, DEF1_ARG(0));
break;
case 'T':
wsemul_vt100_scrolldown(edp, DEF1_ARG(0));
break;
case 'X':
n = min(DEF1_ARG(0), COLS_LEFT + 1);
WSEMULOP(rc, edp, &edp->abortstate, erasecols,
ERASECOLS(edp->ccol, n, edp->bkgdattr));
break;
case 'Z':
if (edp->ccol == 0)
break;
for (m = 0; m < DEF1_ARG(0); m++) {
if (edp->tabs) {
for (n = edp->ccol - 1; n > 0; n--) {
if (edp->tabs[n])
break;
}
} else
n = (edp->ccol - 1) & ~7;
edp->ccol = n;
if (n == 0)
break;
}
break;
case 'b':
n = min(DEF1_ARG(0), 65535);
instate->inchar = instate->last_output;
rc = wsemul_vt100_output_normal(edp, instate, kernel, n);
break;
case 'c':
if (ARG(0) == 0)
wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID1,
sizeof(WSEMUL_VT_ID1) - 1);
break;
case 'd':
edp->crow = min(DEF1_ARG(0), edp->nrows) - 1;
break;
case 'g':
if (edp->tabs != NULL)
switch (ARG(0)) {
case 0:
edp->tabs[edp->ccol] = 0;
break;
case 3:
memset(edp->tabs, 0, edp->ncols);
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%dg unknown\n", ARG(0));
#endif
break;
}
break;
case 'm':
flags = edp->attrflags;
fgcol = edp->fgcol;
bgcol = edp->bgcol;
for (n = 0; n < edp->nargs; n++) {
switch (ARG(n)) {
case 0:
if (n == edp->nargs - 1) {
edp->bkgdattr = edp->curattr = edp->defattr;
edp->attrflags = 0;
edp->fgcol = WSCOL_WHITE;
edp->bgcol = WSCOL_BLACK;
return 0;
}
flags = 0;
fgcol = WSCOL_WHITE;
bgcol = WSCOL_BLACK;
break;
case 1:
flags |= WSATTR_HILIT;
break;
case 4:
flags |= WSATTR_UNDERLINE;
break;
case 5:
flags |= WSATTR_BLINK;
break;
case 7:
flags |= WSATTR_REVERSE;
break;
case 22:
flags &= ~WSATTR_HILIT;
break;
case 24:
flags &= ~WSATTR_UNDERLINE;
break;
case 25:
flags &= ~WSATTR_BLINK;
break;
case 27:
flags &= ~WSATTR_REVERSE;
break;
case 30: case 31: case 32: case 33:
case 34: case 35: case 36: case 37:
flags |= WSATTR_WSCOLORS;
fgcol = ARG(n) - 30;
break;
case 39:
fgcol = WSCOL_WHITE;
if (bgcol == WSCOL_BLACK)
flags &= ~WSATTR_WSCOLORS;
break;
case 40: case 41: case 42: case 43:
case 44: case 45: case 46: case 47:
flags |= WSATTR_WSCOLORS;
bgcol = ARG(n) - 40;
break;
case 49:
bgcol = WSCOL_BLACK;
if (fgcol == WSCOL_WHITE)
flags &= ~WSATTR_WSCOLORS;
break;
case 90: case 91: case 92: case 93:
case 94: case 95: case 96: case 97:
flags |= WSATTR_WSCOLORS;
fgcol = ARG(n) - 82;
break;
case 100: case 101: case 102: case 103:
case 104: case 105: case 106: case 107:
flags |= WSATTR_WSCOLORS;
bgcol = ARG(n) - 92;
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%dm unknown\n", ARG(n));
#endif
break;
}
}
if (vt100_selectattribute(edp, flags, fgcol, bgcol, &attr,
&bkgdattr)) {
#ifdef VT100_DEBUG
printf("error allocating attr %d/%d/%x\n",
fgcol, bgcol, flags);
#endif
} else {
edp->curattr = attr;
edp->bkgdattr = bkgdattr;
edp->attrflags = flags;
edp->fgcol = fgcol;
edp->bgcol = bgcol;
}
break;
case 'n':
switch (ARG(0)) {
case 5:
wsdisplay_emulinput(edp->cbcookie, "\033[0n", 4);
break;
case 6:
{
char buf[20];
int row;
if (edp->flags & VTFL_DECOM) {
row = ROWS_ABOVE;
if (row < 0)
row = 0;
} else
row = edp->crow;
n = snprintf(buf, sizeof buf, "\033[%d;%dR",
row + 1, edp->ccol + 1);
if (n == -1)
n = 0;
else if (n >= sizeof buf)
n = sizeof buf - 1;
wsdisplay_emulinput(edp->cbcookie, buf, n);
}
break;
case 15:
wsdisplay_emulinput(edp->cbcookie, "\033[?13n", 6);
break;
case 25:
wsdisplay_emulinput(edp->cbcookie, "\033[?21n", 6);
break;
case 26:
wsdisplay_emulinput(edp->cbcookie, "\033[?27;1n", 8);
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%dn unknown\n", ARG(0));
#endif
break;
}
break;
case 'r':
help = min(DEF1_ARG(0), edp->nrows) - 1;
n = min(DEFx_ARG(1, edp->nrows), edp->nrows) - help;
if (n < 2) {
return 0;
} else {
edp->scrreg_startrow = help;
edp->scrreg_nrows = n;
}
edp->crow = ((edp->flags & VTFL_DECOM) ?
edp->scrreg_startrow : 0);
edp->ccol = 0;
break;
case 's':
edp->flags |= VTFL_SAVEDCURS;
edp->savedcursor_row = edp->crow;
edp->savedcursor_col = edp->ccol;
break;
case 'u':
if (edp->flags & VTFL_SAVEDCURS) {
edp->crow = edp->savedcursor_row;
edp->ccol = edp->savedcursor_col;
}
break;
case 'y':
switch (ARG(0)) {
case 4:
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI%dy unknown\n", ARG(0));
#endif
break;
}
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("CSI %x (%d, %d) unknown\n",
instate->inchar, ARG(0), ARG(1));
#endif
break;
}
return rc;
}
int
vt100_selectattribute(struct wsemul_vt100_emuldata *edp, int flags, int fgcol,
int bgcol, uint32_t *attr, uint32_t *bkgdattr)
{
int error;
if ((flags & WSATTR_WSCOLORS) &&
!(edp->scrcapabilities & WSSCREEN_WSCOLORS)) {
flags &= ~WSATTR_WSCOLORS;
#ifdef VT100_DEBUG
printf("colors ignored (impossible)\n");
#endif
}
error = (*edp->emulops->pack_attr)(edp->emulcookie, fgcol, bgcol,
flags & WSATTR_WSCOLORS, bkgdattr);
if (error)
return (error);
if ((flags & WSATTR_HILIT) &&
!(edp->scrcapabilities & WSSCREEN_HILIT)) {
flags &= ~WSATTR_HILIT;
if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
fgcol = WSCOL_RED;
flags |= WSATTR_WSCOLORS;
} else {
#ifdef VT100_DEBUG
printf("bold ignored (impossible)\n");
#endif
}
}
if ((flags & WSATTR_UNDERLINE) &&
!(edp->scrcapabilities & WSSCREEN_UNDERLINE)) {
flags &= ~WSATTR_UNDERLINE;
if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
fgcol = WSCOL_CYAN;
flags &= ~WSATTR_UNDERLINE;
flags |= WSATTR_WSCOLORS;
} else {
#ifdef VT100_DEBUG
printf("underline ignored (impossible)\n");
#endif
}
}
if ((flags & WSATTR_BLINK) &&
!(edp->scrcapabilities & WSSCREEN_BLINK)) {
flags &= ~WSATTR_BLINK;
#ifdef VT100_DEBUG
printf("blink ignored (impossible)\n");
#endif
}
if ((flags & WSATTR_REVERSE) &&
!(edp->scrcapabilities & WSSCREEN_REVERSE)) {
flags &= ~WSATTR_REVERSE;
if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
int help;
help = bgcol;
bgcol = fgcol;
fgcol = help;
flags |= WSATTR_WSCOLORS;
} else {
#ifdef VT100_DEBUG
printf("reverse ignored (impossible)\n");
#endif
}
}
error = (*edp->emulops->pack_attr)(edp->emulcookie, fgcol, bgcol,
flags, attr);
if (error)
return (error);
return (0);
}
void
wsemul_vt100_handle_dcs(struct wsemul_vt100_emuldata *edp)
{
int i, pos;
switch (edp->dcstype) {
case 0:
return;
case DCSTYPE_TABRESTORE:
if (edp->tabs != NULL) {
memset(edp->tabs, 0, edp->ncols);
pos = 0;
if (edp->dcsarg == NULL)
goto out;
for (i = 0; i < edp->dcspos; i++) {
char c = edp->dcsarg[i];
switch (c) {
case '0': case '1': case '2': case '3':
case '4': case '5': case '6': case '7':
case '8': case '9':
pos = pos * 10 + (c - '0');
if (pos > edp->ncols)
goto out;
break;
case '/':
if (pos > 0)
edp->tabs[pos - 1] = 1;
pos = 0;
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("unknown char %c in DCS\n", c);
#endif
break;
}
}
if (pos > 0)
edp->tabs[pos - 1] = 1;
}
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("wsemul_vt100_handle_dcs: bad type %d\n", edp->dcstype);
#endif
break;
}
out:
edp->dcstype = 0;
}
int
vt100_ansimode(struct wsemul_vt100_emuldata *edp, int nr, int op)
{
int res = 0;
switch (nr) {
case 2:
break;
case 3:
break;
case 4:
if (op == VTMODE_SET)
edp->flags |= VTFL_INSERTMODE;
else if (op == VTMODE_RESET)
edp->flags &= ~VTFL_INSERTMODE;
res = ((edp->flags & VTFL_INSERTMODE) ? 1 : 2);
break;
case 10:
res = 4;
break;
case 12:
res = 4;
break;
case 20:
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("ANSI mode %d unknown\n", nr);
#endif
break;
}
return (res);
}
int
vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
{
#if 0
int res = 0;
#endif
int flags = edp->flags;
int rc = 0;
switch (nr) {
case 1:
if (op == VTMODE_SET)
flags |= VTFL_APPLCURSOR;
else if (op == VTMODE_RESET)
flags &= ~VTFL_APPLCURSOR;
#if 0
res = ((flags & VTFL_APPLCURSOR) ? 1 : 2);
#endif
break;
case 2:
#if 0
res = 3;
#endif
break;
case 3:
case 4:
case 5:
#if 0
res = 4;
#endif
break;
case 6:
if (op == VTMODE_SET)
flags |= VTFL_DECOM;
else if (op == VTMODE_RESET)
flags &= ~VTFL_DECOM;
#if 0
res = ((flags & VTFL_DECOM) ? 1 : 2);
#endif
break;
case 7:
if (op == VTMODE_SET)
flags |= VTFL_DECAWM;
else if (op == VTMODE_RESET)
flags &= ~VTFL_DECAWM;
#if 0
res = ((flags & VTFL_DECAWM) ? 1 : 2);
#endif
break;
case 8:
break;
case 18:
break;
case 19:
break;
case 25:
if (op == VTMODE_SET)
flags |= VTFL_CURSORON;
else if (op == VTMODE_RESET)
flags &= ~VTFL_CURSORON;
if (flags != edp->flags)
WSEMULOP(rc, edp, &edp->abortstate, cursor,
(edp->emulcookie, flags & VTFL_CURSORON, edp->crow,
edp->ccol));
#if 0
res = ((flags & VTFL_CURSORON) ? 1 : 2);
#endif
break;
case 42:
if (op == VTMODE_SET)
flags |= VTFL_NATCHARSET;
else if (op == VTMODE_RESET)
flags &= ~VTFL_NATCHARSET;
#if 0
res = ((flags & VTFL_NATCHARSET) ? 1 : 2);
#endif
break;
case 66:
break;
case 68:
break;
default:
#ifdef VT100_PRINTUNKNOWN
printf("DEC mode %d unknown\n", nr);
#endif
break;
}
edp->flags = flags;
return rc;
}