2005-12-11 15:16:03 +03:00
|
|
|
/* $NetBSD: wsemul_vt100_subr.c,v 1.19 2005/12/11 12:24:12 christos Exp $ */
|
1998-06-20 23:17:47 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 1998
|
|
|
|
* Matthias Drochner. All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2001-11-13 09:17:46 +03:00
|
|
|
#include <sys/cdefs.h>
|
2005-12-11 15:16:03 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: wsemul_vt100_subr.c,v 1.19 2005/12/11 12:24:12 christos Exp $");
|
2001-11-13 09:17:46 +03:00
|
|
|
|
1998-06-20 23:17:47 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
#include <dev/wscons/wsconsio.h>
|
1998-06-20 23:17:47 +04:00
|
|
|
#include <dev/wscons/wsksymvar.h>
|
|
|
|
#include <dev/wscons/wsdisplayvar.h>
|
|
|
|
#include <dev/wscons/wsemulvar.h>
|
|
|
|
#include <dev/wscons/wsemul_vt100var.h>
|
|
|
|
|
2003-04-02 22:22:56 +04:00
|
|
|
#include "opt_wsemul.h"
|
|
|
|
|
2001-10-13 19:56:15 +04:00
|
|
|
static int vt100_selectattribute(struct wsemul_vt100_emuldata *,
|
|
|
|
int, int, int, long *, long *);
|
|
|
|
static int vt100_ansimode(struct wsemul_vt100_emuldata *, int, int);
|
|
|
|
static int vt100_decmode(struct wsemul_vt100_emuldata *, int, int);
|
1998-06-27 01:20:34 +04:00
|
|
|
#define VTMODE_SET 33
|
|
|
|
#define VTMODE_RESET 44
|
|
|
|
#define VTMODE_REPORT 55
|
1998-06-20 23:17:47 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* scroll up within scrolling region
|
|
|
|
*/
|
|
|
|
void
|
2001-10-13 19:56:15 +04:00
|
|
|
wsemul_vt100_scrollup(struct wsemul_vt100_emuldata *edp, int n)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int help;
|
|
|
|
|
|
|
|
if (n > edp->scrreg_nrows)
|
|
|
|
n = edp->scrreg_nrows;
|
|
|
|
|
|
|
|
help = edp->scrreg_nrows - n;
|
1998-06-27 01:20:34 +04:00
|
|
|
if (help > 0) {
|
1998-06-20 23:17:47 +04:00
|
|
|
(*edp->emulops->copyrows)(edp->emulcookie,
|
|
|
|
edp->scrreg_startrow + n,
|
|
|
|
edp->scrreg_startrow,
|
|
|
|
help);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memmove(&edp->dblwid[edp->scrreg_startrow],
|
|
|
|
&edp->dblwid[edp->scrreg_startrow + n],
|
|
|
|
help);
|
1998-06-27 01:20:34 +04:00
|
|
|
}
|
1998-06-20 23:17:47 +04:00
|
|
|
(*edp->emulops->eraserows)(edp->emulcookie,
|
|
|
|
edp->scrreg_startrow + help, n,
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(&edp->dblwid[edp->scrreg_startrow + help], 0, n);
|
1998-06-27 01:20:34 +04:00
|
|
|
CHECK_DW;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* scroll down within scrolling region
|
|
|
|
*/
|
|
|
|
void
|
2001-10-13 19:56:15 +04:00
|
|
|
wsemul_vt100_scrolldown(struct wsemul_vt100_emuldata *edp, int n)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int help;
|
|
|
|
|
|
|
|
if (n > edp->scrreg_nrows)
|
|
|
|
n = edp->scrreg_nrows;
|
|
|
|
|
|
|
|
help = edp->scrreg_nrows - n;
|
1998-06-27 01:20:34 +04:00
|
|
|
if (help > 0) {
|
1998-06-20 23:17:47 +04:00
|
|
|
(*edp->emulops->copyrows)(edp->emulcookie,
|
|
|
|
edp->scrreg_startrow,
|
|
|
|
edp->scrreg_startrow + n,
|
|
|
|
help);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memmove(&edp->dblwid[edp->scrreg_startrow + n],
|
|
|
|
&edp->dblwid[edp->scrreg_startrow],
|
|
|
|
help);
|
1998-06-27 01:20:34 +04:00
|
|
|
}
|
1998-06-20 23:17:47 +04:00
|
|
|
(*edp->emulops->eraserows)(edp->emulcookie,
|
|
|
|
edp->scrreg_startrow, n,
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(&edp->dblwid[edp->scrreg_startrow], 0, n);
|
1998-06-27 01:20:34 +04:00
|
|
|
CHECK_DW;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* erase in display
|
|
|
|
*/
|
|
|
|
void
|
2001-10-13 19:56:15 +04:00
|
|
|
wsemul_vt100_ed(struct wsemul_vt100_emuldata *edp, int arg)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int n;
|
|
|
|
|
|
|
|
switch (arg) {
|
|
|
|
case 0: /* cursor to end */
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(edp->ccol, COLS_LEFT + 1, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
n = edp->nrows - edp->crow - 1;
|
|
|
|
if (n > 0) {
|
|
|
|
(*edp->emulops->eraserows)(edp->emulcookie,
|
|
|
|
edp->crow + 1, n,
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(&edp->dblwid[edp->crow + 1], 0, n);
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1: /* beginning to cursor */
|
|
|
|
if (edp->crow > 0) {
|
|
|
|
(*edp->emulops->eraserows)(edp->emulcookie,
|
|
|
|
0, edp->crow,
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(&edp->dblwid[0], 0, edp->crow);
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(0, edp->ccol + 1, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 2: /* complete display */
|
|
|
|
(*edp->emulops->eraserows)(edp->emulcookie,
|
|
|
|
0, edp->nrows,
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr);
|
1998-06-27 01:20:34 +04:00
|
|
|
if (edp->dblwid)
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(&edp->dblwid[0], 0, edp->nrows);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("ed(%d) unknown\n", arg);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
1998-06-27 01:20:34 +04:00
|
|
|
CHECK_DW;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* erase in line
|
|
|
|
*/
|
|
|
|
void
|
2001-10-13 19:56:15 +04:00
|
|
|
wsemul_vt100_el(struct wsemul_vt100_emuldata *edp, int arg)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
switch (arg) {
|
|
|
|
case 0: /* cursor to end */
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(edp->ccol, COLS_LEFT + 1, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 1: /* beginning to cursor */
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(0, edp->ccol + 1, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 2: /* complete line */
|
|
|
|
(*edp->emulops->erasecols)(edp->emulcookie, edp->crow,
|
|
|
|
0, edp->ncols,
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("el(%d) unknown\n", arg);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle commands after CSI (ESC[)
|
|
|
|
*/
|
|
|
|
void
|
2001-10-13 19:56:15 +04:00
|
|
|
wsemul_vt100_handle_csi(struct wsemul_vt100_emuldata *edp, u_char c)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int n, help, flags, fgcol, bgcol;
|
2000-04-29 01:56:16 +04:00
|
|
|
long attr, bkgdattr;
|
1998-06-20 23:17:47 +04:00
|
|
|
|
1998-06-27 01:20:34 +04:00
|
|
|
#define A3(a, b, c) (((a) << 16) | ((b) << 8) | (c))
|
|
|
|
switch (A3(edp->modif1, edp->modif2, c)) {
|
|
|
|
case A3('>', '\0', 'c'): /* DA secondary */
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID2,
|
|
|
|
sizeof(WSEMUL_VT_ID2));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case A3('\0', '\0', 'J'): /* ED selective erase in display */
|
|
|
|
case A3('?', '\0', 'J'): /* DECSED selective erase in display */
|
|
|
|
wsemul_vt100_ed(edp, ARG(0));
|
|
|
|
break;
|
|
|
|
case A3('\0', '\0', 'K'): /* EL selective erase in line */
|
|
|
|
case A3('?', '\0', 'K'): /* DECSEL selective erase in line */
|
|
|
|
wsemul_vt100_el(edp, ARG(0));
|
|
|
|
break;
|
|
|
|
case A3('\0', '\0', 'h'): /* SM */
|
|
|
|
for (n = 0; n < edp->nargs; n++)
|
|
|
|
vt100_ansimode(edp, ARG(n), VTMODE_SET);
|
|
|
|
break;
|
|
|
|
case A3('?', '\0', 'h'): /* DECSM */
|
|
|
|
for (n = 0; n < edp->nargs; n++)
|
|
|
|
vt100_decmode(edp, ARG(n), VTMODE_SET);
|
|
|
|
break;
|
|
|
|
case A3('\0', '\0', 'l'): /* RM */
|
|
|
|
for (n = 0; n < edp->nargs; n++)
|
|
|
|
vt100_ansimode(edp, ARG(n), VTMODE_RESET);
|
2003-01-20 08:29:53 +03:00
|
|
|
break;
|
1998-06-27 01:20:34 +04:00
|
|
|
case A3('?', '\0', 'l'): /* DECRM */
|
|
|
|
for (n = 0; n < edp->nargs; n++)
|
|
|
|
vt100_decmode(edp, ARG(n), VTMODE_RESET);
|
2003-01-20 08:29:53 +03:00
|
|
|
break;
|
1998-06-27 01:20:34 +04:00
|
|
|
case A3('\0', '$', 'p'): /* DECRQM request mode ANSI */
|
|
|
|
vt100_ansimode(edp, ARG(0), VTMODE_REPORT);
|
|
|
|
break;
|
|
|
|
case A3('?', '$', 'p'): /* DECRQM request mode DEC */
|
|
|
|
vt100_decmode(edp, ARG(0), VTMODE_REPORT);
|
|
|
|
break;
|
|
|
|
case A3('\0', '\0', 'i'): /* MC printer controller mode */
|
|
|
|
case A3('?', '\0', 'i'): /* MC printer controller mode */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0: /* print screen */
|
|
|
|
case 1: /* print cursor line */
|
|
|
|
case 4: /* off */
|
|
|
|
case 5: /* on */
|
|
|
|
#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'): /* DECSTR soft reset VT300 only */
|
|
|
|
wsemul_vt100_reset(edp);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case A2('"', 'p'): /* DECSCL */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 61: /* VT100 mode (no further arguments!) */
|
|
|
|
break;
|
|
|
|
case 62:
|
|
|
|
case 63: /* VT300 mode */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%d\"p unknown\n", ARG(0));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (ARG(1)) {
|
|
|
|
case 0:
|
|
|
|
case 2: /* 8-bit controls */
|
|
|
|
#ifdef VT100_PRINTNOTIMPL
|
|
|
|
printf("CSI%d;%d\"p ignored\n", ARG(0), ARG(1));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 1: /* 7-bit controls */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%d;%d\"p unknown\n", ARG(0), ARG(1));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case A2('"', 'q'): /* DECSCA select character attribute VT300 */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0:
|
|
|
|
case 1: /* erasable */
|
|
|
|
break;
|
|
|
|
case 2: /* not erasable */
|
|
|
|
#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'): /* DECRQTSR request terminal status report */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0: /* ignored */
|
|
|
|
break;
|
|
|
|
case 1: /* terminal state report */
|
|
|
|
#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'): /* DECRQPSR request presentation status report
|
|
|
|
(VT300 only) */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0: /* error */
|
|
|
|
break;
|
|
|
|
case 1: /* cursor information report */
|
|
|
|
#ifdef VT100_PRINTNOTIMPL
|
|
|
|
printf("CSI1$w ignored\n");
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case 2: /* tab stop report */
|
|
|
|
{
|
2005-05-30 01:56:35 +04:00
|
|
|
int i, j, ps = 0;
|
1998-06-27 01:20:34 +04:00
|
|
|
char buf[20];
|
|
|
|
KASSERT(edp->tabs != 0);
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, "\033P2$u", 5);
|
|
|
|
for (i = 0; i < edp->ncols; i++)
|
|
|
|
if (edp->tabs[i]) {
|
2005-05-30 01:56:35 +04:00
|
|
|
j = snprintf(buf, sizeof(buf), "%s%d",
|
2004-04-24 01:29:16 +04:00
|
|
|
(ps ? "/" : ""), i + 1);
|
1998-06-27 01:20:34 +04:00
|
|
|
wsdisplay_emulinput(edp->cbcookie,
|
2005-05-30 01:56:35 +04:00
|
|
|
buf, j);
|
1998-06-30 01:14:40 +04:00
|
|
|
ps = 1;
|
1998-06-27 01:20:34 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, "\033\\", 2);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%d$w unknown\n", ARG(0));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case A2('$', '}'): /* DECSASD select active status display */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0: /* main display */
|
|
|
|
case 1: /* status line */
|
|
|
|
#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('$', '~'): /* DECSSDD select status line type */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0: /* none */
|
|
|
|
case 1: /* indicator */
|
|
|
|
case 2: /* host-writable */
|
|
|
|
#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'): /* DECRQUPSS request user preferred
|
|
|
|
supplemental set */
|
2003-04-02 21:48:59 +04:00
|
|
|
wsdisplay_emulinput(edp->cbcookie, "\033P0!u%5\033\\", 9);
|
1998-06-27 01:20:34 +04:00
|
|
|
break;
|
|
|
|
|
1998-06-20 23:17:47 +04:00
|
|
|
case '@': /* ICH insert character VT300 only */
|
|
|
|
n = min(DEF1_ARG(0), COLS_LEFT + 1);
|
1998-06-27 01:20:34 +04:00
|
|
|
help = NCOLS - (edp->ccol + n);
|
1998-06-20 23:17:47 +04:00
|
|
|
if (help > 0)
|
1998-06-27 01:20:34 +04:00
|
|
|
COPYCOLS(edp->ccol, edp->ccol + n, help);
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(edp->ccol, n, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 'A': /* CUU */
|
|
|
|
edp->crow -= min(DEF1_ARG(0), ROWS_ABOVE);
|
1998-06-27 01:20:34 +04:00
|
|
|
CHECK_DW;
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 'B': /* CUD */
|
|
|
|
edp->crow += min(DEF1_ARG(0), ROWS_BELOW);
|
1998-06-27 01:20:34 +04:00
|
|
|
CHECK_DW;
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 'C': /* CUF */
|
|
|
|
edp->ccol += min(DEF1_ARG(0), COLS_LEFT);
|
|
|
|
break;
|
|
|
|
case 'D': /* CUB */
|
|
|
|
edp->ccol -= min(DEF1_ARG(0), edp->ccol);
|
|
|
|
edp->flags &= ~VTFL_LASTCHAR;
|
|
|
|
break;
|
|
|
|
case 'H': /* CUP */
|
|
|
|
case 'f': /* HVP */
|
|
|
|
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;
|
1998-06-27 01:20:34 +04:00
|
|
|
CHECK_DW;
|
|
|
|
edp->ccol = min(DEF1_ARG(1), NCOLS) - 1;
|
1998-06-20 23:17:47 +04:00
|
|
|
edp->flags &= ~VTFL_LASTCHAR;
|
|
|
|
break;
|
|
|
|
case 'L': /* IL insert line */
|
|
|
|
case 'M': /* DL delete line */
|
|
|
|
n = min(DEF1_ARG(0), ROWS_BELOW + 1);
|
|
|
|
{
|
1998-06-27 01:20:34 +04:00
|
|
|
int savscrstartrow, savscrnrows;
|
|
|
|
savscrstartrow = edp->scrreg_startrow;
|
|
|
|
savscrnrows = edp->scrreg_nrows;
|
|
|
|
edp->scrreg_nrows -= ROWS_ABOVE;
|
|
|
|
edp->scrreg_startrow = edp->crow;
|
|
|
|
if (c == 'L')
|
|
|
|
wsemul_vt100_scrolldown(edp, n);
|
|
|
|
else
|
|
|
|
wsemul_vt100_scrollup(edp, n);
|
|
|
|
edp->scrreg_startrow = savscrstartrow;
|
|
|
|
edp->scrreg_nrows = savscrnrows;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'P': /* DCH delete character */
|
|
|
|
n = min(DEF1_ARG(0), COLS_LEFT + 1);
|
1998-06-27 01:20:34 +04:00
|
|
|
help = NCOLS - (edp->ccol + n);
|
1998-06-20 23:17:47 +04:00
|
|
|
if (help > 0)
|
1998-06-27 01:20:34 +04:00
|
|
|
COPYCOLS(edp->ccol + n, edp->ccol, help);
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(NCOLS - n, n, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 'X': /* ECH erase character */
|
|
|
|
n = min(DEF1_ARG(0), COLS_LEFT + 1);
|
2000-04-29 01:56:16 +04:00
|
|
|
ERASECOLS(edp->ccol, n, edp->bkgdattr);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 'c': /* DA primary */
|
|
|
|
if (ARG(0) == 0)
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, WSEMUL_VT_ID1,
|
|
|
|
sizeof(WSEMUL_VT_ID1));
|
|
|
|
break;
|
|
|
|
case 'g': /* TBC */
|
|
|
|
KASSERT(edp->tabs != 0);
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 0:
|
|
|
|
edp->tabs[edp->ccol] = 0;
|
|
|
|
break;
|
|
|
|
case 3:
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(edp->tabs, 0, edp->ncols);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%dg unknown\n", ARG(0));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'm': /* SGR select graphic rendition */
|
|
|
|
flags = edp->attrflags;
|
|
|
|
fgcol = edp->fgcol;
|
|
|
|
bgcol = edp->bgcol;
|
|
|
|
for (n = 0; n < edp->nargs; n++) {
|
|
|
|
switch (ARG(n)) {
|
|
|
|
case 0: /* reset */
|
|
|
|
if (n == edp->nargs - 1) {
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr = edp->curattr = edp->defattr;
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
edp->attrflags = edp->msgattrs.default_attrs;
|
|
|
|
edp->fgcol = edp->msgattrs.default_fg;
|
|
|
|
edp->bgcol = edp->msgattrs.default_bg;
|
1998-06-20 23:17:47 +04:00
|
|
|
return;
|
|
|
|
}
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
flags = edp->msgattrs.default_attrs;
|
|
|
|
fgcol = edp->msgattrs.default_fg;
|
|
|
|
bgcol = edp->msgattrs.default_bg;
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 1: /* bold */
|
|
|
|
flags |= WSATTR_HILIT;
|
|
|
|
break;
|
|
|
|
case 4: /* underline */
|
|
|
|
flags |= WSATTR_UNDERLINE;
|
|
|
|
break;
|
|
|
|
case 5: /* blink */
|
|
|
|
flags |= WSATTR_BLINK;
|
|
|
|
break;
|
|
|
|
case 7: /* reverse */
|
|
|
|
flags |= WSATTR_REVERSE;
|
|
|
|
break;
|
|
|
|
case 22: /* ~bold VT300 only */
|
|
|
|
flags &= ~WSATTR_HILIT;
|
|
|
|
break;
|
|
|
|
case 24: /* ~underline VT300 only */
|
|
|
|
flags &= ~WSATTR_UNDERLINE;
|
|
|
|
break;
|
|
|
|
case 25: /* ~blink VT300 only */
|
|
|
|
flags &= ~WSATTR_BLINK;
|
|
|
|
break;
|
|
|
|
case 27: /* ~reverse VT300 only */
|
|
|
|
flags &= ~WSATTR_REVERSE;
|
|
|
|
break;
|
|
|
|
case 30: case 31: case 32: case 33:
|
|
|
|
case 34: case 35: case 36: case 37:
|
|
|
|
/* fg color */
|
|
|
|
flags |= WSATTR_WSCOLORS;
|
|
|
|
fgcol = ARG(n) - 30;
|
|
|
|
break;
|
|
|
|
case 40: case 41: case 42: case 43:
|
|
|
|
case 44: case 45: case 46: case 47:
|
|
|
|
/* bg color */
|
|
|
|
flags |= WSATTR_WSCOLORS;
|
|
|
|
bgcol = ARG(n) - 40;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%dm unknown\n", ARG(n));
|
|
|
|
#endif
|
2001-02-24 03:01:22 +03:00
|
|
|
break;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
}
|
2000-04-29 01:56:16 +04:00
|
|
|
if (vt100_selectattribute(edp, flags, fgcol, bgcol, &attr,
|
|
|
|
&bkgdattr)) {
|
1998-06-20 23:17:47 +04:00
|
|
|
#ifdef VT100_DEBUG
|
|
|
|
printf("error allocating attr %d/%d/%x\n",
|
|
|
|
fgcol, bgcol, flags);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
edp->curattr = attr;
|
2000-04-29 01:56:16 +04:00
|
|
|
edp->bkgdattr = bkgdattr;
|
1998-06-20 23:17:47 +04:00
|
|
|
edp->attrflags = flags;
|
|
|
|
edp->fgcol = fgcol;
|
|
|
|
edp->bgcol = bgcol;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'n': /* reports */
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 5: /* DSR operating status */
|
|
|
|
/* 0 = OK, 3 = malfunction */
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, "\033[0n", 4);
|
|
|
|
break;
|
|
|
|
case 6: { /* DSR cursor position report */
|
|
|
|
char buf[20];
|
|
|
|
int row;
|
|
|
|
if (edp->flags & VTFL_DECOM)
|
|
|
|
row = ROWS_ABOVE;
|
|
|
|
else
|
|
|
|
row = edp->crow;
|
2004-04-24 01:29:16 +04:00
|
|
|
n = snprintf(buf, sizeof(buf), "\033[%d;%dR",
|
|
|
|
row + 1, edp->ccol + 1);
|
1998-06-20 23:17:47 +04:00
|
|
|
wsdisplay_emulinput(edp->cbcookie, buf, n);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 15: /* DSR printer status */
|
|
|
|
/* 13 = no printer, 10 = ready, 11 = not ready */
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, "\033[?13n", 6);
|
|
|
|
break;
|
|
|
|
case 25: /* UDK status - VT300 only */
|
|
|
|
/* 20 = locked, 21 = unlocked */
|
|
|
|
wsdisplay_emulinput(edp->cbcookie, "\033[?21n", 6);
|
|
|
|
break;
|
|
|
|
case 26: /* keyboard dialect */
|
|
|
|
/* 1 = north american , 7 = german */
|
|
|
|
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': /* DECSTBM set top/bottom margins */
|
1998-08-13 00:04:12 +04:00
|
|
|
help = min(DEF1_ARG(0), edp->nrows) - 1;
|
|
|
|
n = min(DEFx_ARG(1, edp->nrows), edp->nrows) - help;
|
|
|
|
if (n < 2) {
|
|
|
|
/* minimal scrolling region has 2 lines */
|
|
|
|
return;
|
1998-06-20 23:17:47 +04:00
|
|
|
} else {
|
1998-08-13 00:04:12 +04:00
|
|
|
edp->scrreg_startrow = help;
|
|
|
|
edp->scrreg_nrows = n;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
edp->crow = ((edp->flags & VTFL_DECOM) ?
|
|
|
|
edp->scrreg_startrow : 0);
|
|
|
|
edp->ccol = 0;
|
|
|
|
break;
|
|
|
|
case 'y':
|
|
|
|
switch (ARG(0)) {
|
|
|
|
case 4: /* DECTST invoke confidence test */
|
|
|
|
/* ignore */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%dy unknown\n", ARG(0));
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("CSI%c (%d, %d) unknown\n", c, ARG(0), ARG(1));
|
|
|
|
#endif
|
2001-02-24 03:01:22 +03:00
|
|
|
break;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* get an attribute from the graphics driver,
|
|
|
|
* try to find replacements if the desired appearance
|
|
|
|
* is not supported
|
|
|
|
*/
|
|
|
|
static int
|
2001-10-13 19:56:15 +04:00
|
|
|
vt100_selectattribute(struct wsemul_vt100_emuldata *edp,
|
|
|
|
int flags, int fgcol, int bgcol, long *attr, long *bkgdattr)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
2000-04-29 01:56:16 +04:00
|
|
|
int error;
|
|
|
|
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
if (!(edp->scrcapabilities & WSSCREEN_WSCOLORS)) {
|
2000-04-29 01:56:16 +04:00
|
|
|
flags &= ~WSATTR_WSCOLORS;
|
|
|
|
#ifdef VT100_DEBUG
|
|
|
|
printf("colors ignored (impossible)\n");
|
|
|
|
#endif
|
Implement support to dynamically change wscons console and kernel colors.
Two new ioctls are added to the wsdisplay device, named WSDISPLAY_GMSGATTRS
and WSDISPLAY_SMSGATTRS, used to retrieve the actual values and set them,
respectively (the name, if you are wondering, comes from "message attributes").
A new emulop is added to the underlying display driver (only vga, for now)
which sets the new attribute for the whole screen, without having to clear
it. This is optional, which means that this also works with other drivers
that don't have this new operation.
Five new kernel options have been added, although only documented in
i386 kernels (for now):
- WSDISPLAY_CUSTOM_OUTPUT, which enables the ioctls described above to
change the colors dynamically from userland. This is enabled by default
in the GENERIC kernel (as well as others) but disabled on all INSTALL*
kernels (as this feature is useless there).
- WS_DEFAULT_COLATTR, WS_DEFAULT_MONOATTR, WS_DEFAULT_BG and WS_DEFAULT_FG,
which specify the default colors for the console at boot time. These have
the same meaning as the (already existing) WS_KERNEL_* variables.
wsconsctl is modified to add msg.default.{attrs,bg,fg} and
msg.kernel.{attrs,bg,fg} to the display part, so that colors can be changed
after boot.
Tested on NetBSD/i386 with vga (and vga in mono mode), and on NetBSD/mac68k.
No objections in tech-kern@.
2004-07-28 16:34:02 +04:00
|
|
|
} else
|
|
|
|
flags |= WSATTR_WSCOLORS;
|
2002-07-04 18:37:10 +04:00
|
|
|
error = (*edp->emulops->allocattr)(edp->emulcookie, fgcol, bgcol,
|
|
|
|
flags & WSATTR_WSCOLORS, bkgdattr);
|
2000-04-29 01:56:16 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
1998-06-20 23:17:47 +04:00
|
|
|
if ((flags & WSATTR_HILIT) &&
|
|
|
|
!(edp->scrcapabilities & WSSCREEN_HILIT)) {
|
|
|
|
flags &= ~WSATTR_HILIT;
|
|
|
|
if (edp->scrcapabilities & WSSCREEN_WSCOLORS) {
|
2003-04-02 22:22:56 +04:00
|
|
|
#if defined(WSEMUL_VT100_HILIT_FG) && WSEMUL_VT100_HILIT_FG != -1
|
|
|
|
fgcol = WSEMUL_VT100_HILIT_FG;
|
|
|
|
#elif !defined(WSEMUL_VT100_HILIT_FG)
|
1998-06-20 23:17:47 +04:00
|
|
|
fgcol = WSCOL_RED;
|
2003-04-02 22:22:56 +04:00
|
|
|
#endif
|
|
|
|
#if defined(WSEMUL_VT100_HILIT_BG) && WSEMUL_VT100_HILIT_BG != -1
|
|
|
|
bgcol = WSEMUL_VT100_HILIT_BG;
|
|
|
|
#endif
|
1998-06-20 23:17:47 +04:00
|
|
|
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) {
|
2003-04-02 22:22:56 +04:00
|
|
|
#if defined(WSEMUL_VT100_UNDERLINE_FG) && WSEMUL_VT100_UNDERLINE_FG != -1
|
|
|
|
fgcol = WSEMUL_VT100_UNDERLINE_FG;
|
|
|
|
#endif
|
|
|
|
#if defined(WSEMUL_VT100_UNDERLINE_BG) && WSEMUL_VT100_UNDERLINE_BG != -1
|
|
|
|
bgcol = WSEMUL_VT100_UNDERLINE_BG;
|
|
|
|
#elif !defined(WSEMUL_VT100_UNDERLINE_BG)
|
1998-06-20 23:17:47 +04:00
|
|
|
bgcol = WSCOL_BROWN;
|
2003-04-02 22:22:56 +04:00
|
|
|
#endif
|
1998-06-20 23:17:47 +04:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2002-07-04 18:37:10 +04:00
|
|
|
error = (*edp->emulops->allocattr)(edp->emulcookie, fgcol, bgcol,
|
|
|
|
flags, attr);
|
2000-04-29 01:56:16 +04:00
|
|
|
if (error)
|
|
|
|
return (error);
|
|
|
|
|
|
|
|
return (0);
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* handle device control sequences if the main state machine
|
|
|
|
* told so by setting edp->dcstype to a nonzero value
|
|
|
|
*/
|
|
|
|
void
|
2001-10-13 19:56:15 +04:00
|
|
|
wsemul_vt100_handle_dcs(struct wsemul_vt100_emuldata *edp)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int i, pos;
|
|
|
|
|
|
|
|
switch (edp->dcstype) {
|
|
|
|
case 0: /* not handled */
|
|
|
|
return;
|
|
|
|
case DCSTYPE_TABRESTORE:
|
|
|
|
KASSERT(edp->tabs != 0);
|
1999-01-10 03:28:21 +03:00
|
|
|
memset(edp->tabs, 0, edp->ncols);
|
1998-06-20 23:17:47 +04:00
|
|
|
pos = 0;
|
|
|
|
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 + (edp->dcsarg[i] - '0');
|
|
|
|
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
|
2001-02-24 03:01:22 +03:00
|
|
|
break;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (pos > 0)
|
|
|
|
edp->tabs[pos - 1] = 1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
panic("wsemul_vt100_handle_dcs: bad type %d", edp->dcstype);
|
|
|
|
}
|
|
|
|
edp->dcstype = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-10-13 19:56:15 +04:00
|
|
|
vt100_ansimode(struct wsemul_vt100_emuldata *edp, int nr, int op)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int res = 0; /* default: unknown */
|
|
|
|
|
|
|
|
switch (nr) {
|
|
|
|
case 2: /* KAM keyboard locked/unlocked */
|
|
|
|
break;
|
|
|
|
case 3: /* CRM control representation */
|
|
|
|
break;
|
|
|
|
case 4: /* IRM insert/replace characters */
|
1998-06-27 01:20:34 +04:00
|
|
|
if (op == VTMODE_SET)
|
1998-06-20 23:17:47 +04:00
|
|
|
edp->flags |= VTFL_INSERTMODE;
|
1998-06-27 01:20:34 +04:00
|
|
|
else if (op == VTMODE_RESET)
|
1998-06-20 23:17:47 +04:00
|
|
|
edp->flags &= ~VTFL_INSERTMODE;
|
|
|
|
res = ((edp->flags & VTFL_INSERTMODE) ? 1 : 2);
|
|
|
|
break;
|
|
|
|
case 10: /* HEM horizontal editing (permanently reset) */
|
|
|
|
res = 4;
|
|
|
|
break;
|
|
|
|
case 12: /* SRM local echo off/on */
|
|
|
|
res = 4; /* permanently reset ??? */
|
|
|
|
break;
|
|
|
|
case 20: /* LNM newline = newline/linefeed */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("ANSI mode %d unknown\n", nr);
|
|
|
|
#endif
|
2001-02-24 03:01:22 +03:00
|
|
|
break;
|
1998-06-20 23:17:47 +04:00
|
|
|
}
|
|
|
|
return (res);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-10-13 19:56:15 +04:00
|
|
|
vt100_decmode(struct wsemul_vt100_emuldata *edp, int nr, int op)
|
1998-06-20 23:17:47 +04:00
|
|
|
{
|
|
|
|
int res = 0; /* default: unknown */
|
2000-02-25 20:42:51 +03:00
|
|
|
int flags;
|
1998-06-20 23:17:47 +04:00
|
|
|
|
2000-02-25 20:42:51 +03:00
|
|
|
flags = edp->flags;
|
1998-06-20 23:17:47 +04:00
|
|
|
switch (nr) {
|
|
|
|
case 1: /* DECCKM application/nomal cursor keys */
|
1998-06-27 01:20:34 +04:00
|
|
|
if (op == VTMODE_SET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags |= VTFL_APPLCURSOR;
|
1998-06-27 01:20:34 +04:00
|
|
|
else if (op == VTMODE_RESET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags &= ~VTFL_APPLCURSOR;
|
|
|
|
res = ((flags & VTFL_APPLCURSOR) ? 1 : 2);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 2: /* DECANM ANSI vt100/vt52 */
|
|
|
|
res = 3; /* permanently set ??? */
|
|
|
|
break;
|
|
|
|
case 3: /* DECCOLM 132/80 cols */
|
|
|
|
case 4: /* DECSCLM smooth/jump scroll */
|
|
|
|
case 5: /* DECSCNM light/dark background */
|
|
|
|
res = 4; /* all permanently reset ??? */
|
|
|
|
break;
|
|
|
|
case 6: /* DECOM move within/outside margins */
|
1998-06-27 01:20:34 +04:00
|
|
|
if (op == VTMODE_SET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags |= VTFL_DECOM;
|
1998-06-27 01:20:34 +04:00
|
|
|
else if (op == VTMODE_RESET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags &= ~VTFL_DECOM;
|
|
|
|
res = ((flags & VTFL_DECOM) ? 1 : 2);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 7: /* DECAWM autowrap */
|
1998-06-27 01:20:34 +04:00
|
|
|
if (op == VTMODE_SET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags |= VTFL_DECAWM;
|
1998-06-27 01:20:34 +04:00
|
|
|
else if (op == VTMODE_RESET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags &= ~VTFL_DECAWM;
|
|
|
|
res = ((flags & VTFL_DECAWM) ? 1 : 2);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 8: /* DECARM keyboard autorepeat */
|
|
|
|
break;
|
|
|
|
case 18: /* DECPFF print form feed */
|
|
|
|
break;
|
|
|
|
case 19: /* DECPEX printer extent: screen/scrolling region */
|
|
|
|
break;
|
|
|
|
case 25: /* DECTCEM text cursor on/off */
|
2000-02-25 20:42:51 +03:00
|
|
|
if (op == VTMODE_SET)
|
|
|
|
flags |= VTFL_CURSORON;
|
|
|
|
else if (op == VTMODE_RESET)
|
|
|
|
flags &= ~VTFL_CURSORON;
|
|
|
|
if (flags != edp->flags)
|
1998-06-20 23:17:47 +04:00
|
|
|
(*edp->emulops->cursor)(edp->emulcookie,
|
2000-02-25 20:42:51 +03:00
|
|
|
flags & VTFL_CURSORON,
|
1998-06-20 23:17:47 +04:00
|
|
|
edp->crow, edp->ccol);
|
2000-02-25 20:42:51 +03:00
|
|
|
res = ((flags & VTFL_CURSORON) ? 1 : 2);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 42: /* DECNRCM use 7-bit NRC /
|
|
|
|
7/8 bit from DEC multilingual or ISO-latin-1*/
|
1998-06-27 01:20:34 +04:00
|
|
|
if (op == VTMODE_SET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags |= VTFL_NATCHARSET;
|
1998-06-27 01:20:34 +04:00
|
|
|
else if (op == VTMODE_RESET)
|
2000-02-25 20:42:51 +03:00
|
|
|
flags &= ~VTFL_NATCHARSET;
|
|
|
|
res = ((flags & VTFL_NATCHARSET) ? 1 : 2);
|
1998-06-20 23:17:47 +04:00
|
|
|
break;
|
|
|
|
case 66: /* DECNKM numeric keypad */
|
|
|
|
break;
|
|
|
|
case 68: /* DECKBUM keyboard usage data processing/typewriter */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
#ifdef VT100_PRINTUNKNOWN
|
|
|
|
printf("DEC mode %d unknown\n", nr);
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
}
|
2000-02-25 20:42:51 +03:00
|
|
|
edp->flags = flags;
|
|
|
|
|
1998-06-20 23:17:47 +04:00
|
|
|
return (res);
|
|
|
|
}
|