int
sc_vid_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
{
    scr_stat *scp;
    video_adapter_t *adp;
    video_info_t info;
    video_adapter_info_t adp_info;
    int error;
    int s;
#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    int ival;
#endif

    scp = SC_STAT(tp);
    if (scp == NULL)		/* tp == SC_MOUSE */
        return ENOIOCTL;
    adp = scp->sc->adp;
    if (adp == NULL)		/* shouldn't happen??? */
        return ENODEV;

    switch (cmd) {

    case CONS_CURRENTADP:	/* get current adapter index */
    case FBIO_ADAPTER:
        return fb_ioctl(adp, FBIO_ADAPTER, data);

    case CONS_CURRENT:  	/* get current adapter type */
    case FBIO_ADPTYPE:
        return fb_ioctl(adp, FBIO_ADPTYPE, data);

    case OLD_CONS_ADPINFO:	/* adapter information (old interface) */
        if (((old_video_adapter_t *)data)->va_index >= 0) {
            adp = vid_get_adapter(((old_video_adapter_t *)data)->va_index);
            if (adp == NULL)
                return ENODEV;
        }
        ((old_video_adapter_t *)data)->va_index = adp->va_index;
        ((old_video_adapter_t *)data)->va_type = adp->va_type;
        ((old_video_adapter_t *)data)->va_flags = adp->va_flags;
        ((old_video_adapter_t *)data)->va_crtc_addr = adp->va_crtc_addr;
        ((old_video_adapter_t *)data)->va_window = adp->va_window;
        ((old_video_adapter_t *)data)->va_window_size = adp->va_window_size;
        ((old_video_adapter_t *)data)->va_window_gran = adp->va_window_gran;
        ((old_video_adapter_t *)data)->va_buffer = adp->va_buffer;
        ((old_video_adapter_t *)data)->va_buffer_size = adp->va_buffer_size;
        ((old_video_adapter_t *)data)->va_mode = adp->va_mode;
        ((old_video_adapter_t *)data)->va_initial_mode = adp->va_initial_mode;
        ((old_video_adapter_t *)data)->va_initial_bios_mode
            = adp->va_initial_bios_mode;
        return 0;

    case OLD_CONS_ADPINFO2:	/* adapter information (yet another old I/F) */
        adp_info.va_index = ((old_video_adapter_info_t *)data)->va_index;
        if (adp_info.va_index >= 0) {
            adp = vid_get_adapter(adp_info.va_index);
            if (adp == NULL)
                return ENODEV;
        }
        error = fb_ioctl(adp, FBIO_ADPINFO, &adp_info);
        if (error == 0)
            bcopy(&adp_info, data, sizeof(old_video_adapter_info_t));
        return error;

    case CONS_ADPINFO:		/* adapter information */
    case FBIO_ADPINFO:
        if (((video_adapter_info_t *)data)->va_index >= 0) {
            adp = vid_get_adapter(((video_adapter_info_t *)data)->va_index);
            if (adp == NULL)
                return ENODEV;
        }
        return fb_ioctl(adp, FBIO_ADPINFO, data);

    case CONS_GET:      	/* get current video mode */
    case FBIO_GETMODE:
        *(int *)data = scp->mode;
        return 0;

#ifndef SC_NO_MODE_CHANGE
    case FBIO_SETMODE:		/* set video mode */
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        info.vi_mode = *(int *)data;
        error = fb_ioctl(adp, FBIO_MODEINFO, &info);
        if (error)
            return error;
        if (info.vi_flags & V_INFO_GRAPHICS)
            return sc_set_graphics_mode(scp, tp, *(int *)data);
        else
            return sc_set_text_mode(scp, tp, *(int *)data, 0, 0, 0, 0);
#endif /* SC_NO_MODE_CHANGE */

    case OLD_CONS_MODEINFO:	/* get mode information (old infterface) */
        info.vi_mode = ((old_video_info_t *)data)->vi_mode;
        error = fb_ioctl(adp, FBIO_MODEINFO, &info);
        if (error == 0)
            bcopy(&info, (old_video_info_t *)data, sizeof(old_video_info_t));
        return error;

    case CONS_MODEINFO:		/* get mode information */
    case FBIO_MODEINFO:
        return fb_ioctl(adp, FBIO_MODEINFO, data);

    case OLD_CONS_FINDMODE:	/* find a matching video mode (old interface) */
        bzero(&info, sizeof(info));
        bcopy((old_video_info_t *)data, &info, sizeof(old_video_info_t));
        error = fb_ioctl(adp, FBIO_FINDMODE, &info);
        if (error == 0)
            bcopy(&info, (old_video_info_t *)data, sizeof(old_video_info_t));
        return error;

    case CONS_FINDMODE:		/* find a matching video mode */
    case FBIO_FINDMODE:
        return fb_ioctl(adp, FBIO_FINDMODE, data);

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    case _IO('c', 104):
        ival = IOCPARM_IVAL(data);
        data = (caddr_t)&ival;
        /* FALLTHROUGH */
#endif
    case CONS_SETWINORG:	/* set frame buffer window origin */
    case FBIO_SETWINORG:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, FBIO_SETWINORG, data);

    case FBIO_GETWINORG:	/* get frame buffer window origin */
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, FBIO_GETWINORG, data);

    case FBIO_GETDISPSTART:
    case FBIO_SETDISPSTART:
    case FBIO_GETLINEWIDTH:
    case FBIO_SETLINEWIDTH:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

    case FBIO_GETPALETTE:
    case FBIO_SETPALETTE:
    case FBIOPUTCMAP:
    case FBIOGETCMAP:
    case FBIOGTYPE:
    case FBIOGATTR:
    case FBIOSVIDEO:
    case FBIOGVIDEO:
    case FBIOSCURSOR:
    case FBIOGCURSOR:
    case FBIOSCURPOS:
    case FBIOGCURPOS:
    case FBIOGCURMAX:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

    case FBIO_BLANK:
        if (scp != scp->sc->cur_scp)
            return ENODEV;	/* XXX */
        return fb_ioctl(adp, cmd, data);

#ifndef SC_NO_MODE_CHANGE
    /* generic text modes */
    case SW_TEXT_80x25:
    case SW_TEXT_80x30:
    case SW_TEXT_80x43:
    case SW_TEXT_80x50:
    case SW_TEXT_80x60:
    /* FALLTHROUGH */

    /* VGA TEXT MODES */
    case SW_VGA_C40x25:
    case SW_VGA_C80x25:
    case SW_VGA_M80x25:
    case SW_VGA_C80x30:
    case SW_VGA_M80x30:
    case SW_VGA_C80x50:
    case SW_VGA_M80x50:
    case SW_VGA_C80x60:
    case SW_VGA_M80x60:
    case SW_VGA_C90x25:
    case SW_VGA_M90x25:
    case SW_VGA_C90x30:
    case SW_VGA_M90x30:
    case SW_VGA_C90x43:
    case SW_VGA_M90x43:
    case SW_VGA_C90x50:
    case SW_VGA_M90x50:
    case SW_VGA_C90x60:
    case SW_VGA_M90x60:
    case SW_B40x25:
    case SW_C40x25:
    case SW_B80x25:
    case SW_C80x25:
    case SW_ENH_B40x25:
    case SW_ENH_C40x25:
    case SW_ENH_B80x25:
    case SW_ENH_C80x25:
    case SW_ENH_B80x43:
    case SW_ENH_C80x43:
    case SW_EGAMONO80x25:

#ifdef PC98
    /* PC98 TEXT MODES */
    case SW_PC98_80x25:
    case SW_PC98_80x30:
#endif
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        return sc_set_text_mode(scp, tp, cmd & 0xff, 0, 0, 0, 0);

    /* GRAPHICS MODES */
    case SW_BG320:
    case SW_BG640:
    case SW_CG320:
    case SW_CG320_D:
    case SW_CG640_E:
    case SW_CG640x350:
    case SW_ENH_CG640:
    case SW_BG640x480:
    case SW_CG640x480:
    case SW_VGA_CG320:
    case SW_VGA_MODEX:
#ifdef PC98
    /* PC98 GRAPHICS MODES */
    case SW_PC98_EGC640x400:
    case SW_PC98_PEGC640x400:
    case SW_PC98_PEGC640x480:
#endif
        if (!(adp->va_flags & V_ADP_MODECHANGE))
            return ENODEV;
        return sc_set_graphics_mode(scp, tp, cmd & 0xff);
#endif /* SC_NO_MODE_CHANGE */

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
    case _IO('K', 10):
        ival = IOCPARM_IVAL(data);
        data = (caddr_t)&ival;
        /* FALLTHROUGH */
#endif
    case KDSETMODE:     	/* set current mode of this (virtual) console */
        switch (*(int *)data) {
        case KD_TEXT:   	/* switch to TEXT (known) mode */
            /*
             * If scp->mode is of graphics modes, we don't know which
             * text mode to switch back to...
             */
            if (scp->status & GRAPHICS_MODE)
                return EINVAL;
            /* restore fonts & palette ! */
#if 0
#ifndef SC_NO_FONT_LOADING
            if (ISFONTAVAIL(adp->va_flags)
                    && !(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
                /*
                 * FONT KLUDGE
                 * Don't load fonts for now... XXX
                 */
                if (scp->sc->fonts_loaded & FONT_8)
                    sc_load_font(scp, 0, 8, 8, scp->sc->font_8, 0, 256);
            if (scp->sc->fonts_loaded & FONT_14)
                sc_load_font(scp, 0, 14, 8, scp->sc->font_14, 0, 256);
            if (scp->sc->fonts_loaded & FONT_16)
                sc_load_font(scp, 0, 16, 8, scp->sc->font_16, 0, 256);
        }
#endif /* SC_NO_FONT_LOADING */
#endif

#ifndef SC_NO_PALETTE_LOADING
        vidd_load_palette(adp, scp->sc->palette);
#endif

#ifndef PC98
        /* move hardware cursor out of the way */
        vidd_set_hw_cursor(adp, -1, -1);
#endif

    /* FALLTHROUGH */

    case KD_TEXT1:  	/* switch to TEXT (known) mode */
        /*
         * If scp->mode is of graphics modes, we don't know which
         * text/pixel mode to switch back to...
         */
        if (scp->status & GRAPHICS_MODE)
            return EINVAL;
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
#ifndef PC98
        scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
        splx(s);
        /* no restore fonts & palette */
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
        sc_clear_screen(scp);
        scp->status &= ~UNKNOWN_MODE;
#else /* PC98 */
        scp->status &= ~UNKNOWN_MODE;
        /* no restore fonts & palette */
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
        sc_clear_screen(scp);
        splx(s);
#endif /* PC98 */
        return 0;

#ifdef SC_PIXEL_MODE
    case KD_PIXEL:		/* pixel (raster) display */
        if (!(scp->status & (GRAPHICS_MODE | PIXEL_MODE)))
            return EINVAL;
        if (scp->status & GRAPHICS_MODE)
            return sc_set_pixel_mode(scp, tp, scp->xsize, scp->ysize,
                                     scp->font_size, scp->font_width);
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
        scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
        splx(s);
        if (scp == scp->sc->cur_scp) {
            set_mode(scp);
#ifndef SC_NO_PALETTE_LOADING
            vidd_load_palette(adp, scp->sc->palette);
#endif
        }
        sc_clear_screen(scp);
        scp->status &= ~UNKNOWN_MODE;
        return 0;
#endif /* SC_PIXEL_MODE */

    case KD_GRAPHICS:	/* switch to GRAPHICS (unknown) mode */
        s = spltty();
        if ((error = sc_clean_up(scp))) {
            splx(s);
            return error;
        }
        scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
        splx(s);
#ifdef PC98
        if (scp == scp->sc->cur_scp)
            set_mode(scp);
#endif
        return 0;

    default:
        return EINVAL;
    }
    /* NOT REACHED */

#ifdef SC_PIXEL_MODE
case KDRASTER:		/* set pixel (raster) display mode */
    if (ISUNKNOWNSC(scp) || ISTEXTSC(scp))
        return ENODEV;
    return sc_set_pixel_mode(scp, tp, ((int *)data)[0], ((int *)data)[1],
                             ((int *)data)[2], 8);
#endif /* SC_PIXEL_MODE */

case KDGETMODE:     	/* get current mode of this (virtual) console */
    /*
     * From the user program's point of view, KD_PIXEL is the same
     * as KD_TEXT...
     */
    *data = ISGRAPHSC(scp) ? KD_GRAPHICS : KD_TEXT;
    return 0;

#if defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD5) || \
    defined(COMPAT_FREEBSD4) || defined(COMPAT_43)
case _IO('K', 13):
    ival = IOCPARM_IVAL(data);
    data = (caddr_t)&ival;
    /* FALLTHROUGH */
#endif
case KDSBORDER:     	/* set border color of this (virtual) console */
    scp->border = *(int *)data;
    if (scp == scp->sc->cur_scp)
        sc_set_border(scp, scp->border);
    return 0;
}
Example #2
0
static void
scterm_scan_esc(scr_stat *scp, term_stat *tcp, u_char c)
{
	static u_char ansi_col[16] = {
		FG_BLACK,     FG_RED,          FG_GREEN,      FG_BROWN,
		FG_BLUE,      FG_MAGENTA,      FG_CYAN,       FG_LIGHTGREY,
		FG_DARKGREY,  FG_LIGHTRED,     FG_LIGHTGREEN, FG_YELLOW,
		FG_LIGHTBLUE, FG_LIGHTMAGENTA, FG_LIGHTCYAN,  FG_WHITE
	};
	sc_softc_t *sc;
	int i, n;

    i = n = 0;
    sc = scp->sc; 
    if (tcp->esc == 1) {	/* seen ESC */
	switch (c) {

	case '7':   /* Save cursor position */
	    tcp->saved_xpos = scp->xpos;
	    tcp->saved_ypos = scp->ypos;
	    break;

	case '8':   /* Restore saved cursor position */
	    if (tcp->saved_xpos >= 0 && tcp->saved_ypos >= 0)
		sc_move_cursor(scp, tcp->saved_xpos, tcp->saved_ypos);
	    break;

	case '[':   /* Start ESC [ sequence */
	    tcp->esc = 2;
	    tcp->last_param = -1;
	    for (i = tcp->num_param; i < MAX_ESC_PAR; i++)
		tcp->param[i] = 1;
	    tcp->num_param = 0;
	    return;

	case 'M':   /* Move cursor up 1 line, scroll if at top */
	    sc_term_up_scroll(scp, 1, sc->scr_map[0x20], tcp->cur_attr, 0, 0);
	    break;
#if notyet
	case 'Q':
	    tcp->esc = 4;
	    return;
#endif
	case 'c':   /* Clear screen & home */
	    sc_clear_screen(scp);
	    break;

	case '(':   /* iso-2022: designate 94 character set to G0 */
	    tcp->esc = 5;
	    return;
	}
    }
    else if (tcp->esc == 2) {	/* seen ESC [ */
	if (c >= '0' && c <= '9') {
	    if (tcp->num_param < MAX_ESC_PAR) {
		if (tcp->last_param != tcp->num_param) {
		    tcp->last_param = tcp->num_param;
		    tcp->param[tcp->num_param] = 0;
		} else {
		    tcp->param[tcp->num_param] *= 10;
		}
		tcp->param[tcp->num_param] += c - '0';
		return;
	    }
	}
	tcp->num_param = tcp->last_param + 1;
	switch (c) {

	case ';':
	    if (tcp->num_param < MAX_ESC_PAR)
		return;
	    break;

	case '=':
	    tcp->esc = 3;
	    tcp->last_param = -1;
	    for (i = tcp->num_param; i < MAX_ESC_PAR; i++)
		tcp->param[i] = 1;
	    tcp->num_param = 0;
	    return;

	case 'A':   /* up n rows */
	    sc_term_up(scp, tcp->param[0], 0);
	    break;

	case 'B':   /* down n rows */
	    sc_term_down(scp, tcp->param[0], 0);
	    break;

	case 'C':   /* right n columns */
	    sc_term_right(scp, tcp->param[0]);
	    break;

	case 'D':   /* left n columns */
	    sc_term_left(scp, tcp->param[0]);
	    break;

	case 'E':   /* cursor to start of line n lines down */
	    n = tcp->param[0]; if (n < 1) n = 1;
	    sc_move_cursor(scp, 0, scp->ypos + n);
	    break;

	case 'F':   /* cursor to start of line n lines up */
	    n = tcp->param[0]; if (n < 1) n = 1;
	    sc_move_cursor(scp, 0, scp->ypos - n);
	    break;

	case 'f':   /* Cursor move */
	case 'H':
	    if (tcp->num_param == 0)
		sc_move_cursor(scp, 0, 0);
	    else if (tcp->num_param == 2)
		sc_move_cursor(scp, tcp->param[1] - 1, tcp->param[0] - 1);
	    break;

	case 'J':   /* Clear all or part of display */
	    if (tcp->num_param == 0)
		n = 0;
	    else
		n = tcp->param[0];
	    sc_term_clr_eos(scp, n, sc->scr_map[0x20], tcp->cur_attr);
	    break;

	case 'K':   /* Clear all or part of line */
	    if (tcp->num_param == 0)
		n = 0;
	    else
		n = tcp->param[0];
	    sc_term_clr_eol(scp, n, sc->scr_map[0x20], tcp->cur_attr);
	    break;

	case 'L':   /* Insert n lines */
	    sc_term_ins_line(scp, scp->ypos, tcp->param[0],
			     sc->scr_map[0x20], tcp->cur_attr, 0);
	    break;

	case 'M':   /* Delete n lines */
	    sc_term_del_line(scp, scp->ypos, tcp->param[0],
			     sc->scr_map[0x20], tcp->cur_attr, 0);
	    break;

	case 'P':   /* Delete n chars */
	    sc_term_del_char(scp, tcp->param[0],
			     sc->scr_map[0x20], tcp->cur_attr);
	    break;

	case '@':   /* Insert n chars */
	    sc_term_ins_char(scp, tcp->param[0],
			     sc->scr_map[0x20], tcp->cur_attr);
	    break;

	case 'S':   /* scroll up n lines */
	    sc_term_del_line(scp, 0, tcp->param[0],
			     sc->scr_map[0x20], tcp->cur_attr, 0);
	    break;

	case 'T':   /* scroll down n lines */
	    sc_term_ins_line(scp, 0, tcp->param[0],
			     sc->scr_map[0x20], tcp->cur_attr, 0);
	    break;

	case 'X':   /* erase n characters in line */
	    n = tcp->param[0]; if (n < 1)  n = 1;
	    if (n > scp->xsize - scp->xpos)
		n = scp->xsize - scp->xpos;
	    sc_vtb_erase(&scp->vtb, scp->cursor_pos, n,
			 sc->scr_map[0x20], tcp->cur_attr);
	    mark_for_update(scp, scp->cursor_pos);
	    mark_for_update(scp, scp->cursor_pos + n - 1);
	    break;

	case 'Z':   /* move n tabs backwards */
	    sc_term_backtab(scp, tcp->param[0]);
	    break;

	case '`':   /* move cursor to column n */
	    sc_term_col(scp, tcp->param[0]);
	    break;

	case 'a':   /* move cursor n columns to the right */
	    sc_term_right(scp, tcp->param[0]);
	    break;

	case 'd':   /* move cursor to row n */
	    sc_term_row(scp, tcp->param[0]);
	    break;

	case 'e':   /* move cursor n rows down */
	    sc_term_down(scp, tcp->param[0], 0);
	    break;

	case 'm':   /* change attribute */
	    if (tcp->num_param == 0) {
		tcp->attr_mask = NORMAL_ATTR;
		tcp->cur_color = tcp->std_color;
		tcp->cur_attr = mask2attr(tcp);
		break;
	    }
	    for (i = 0; i < tcp->num_param; i++) {
		switch (n = tcp->param[i]) {
		case 0: /* back to normal */
		    tcp->attr_mask = NORMAL_ATTR;
		    tcp->cur_color = tcp->std_color;
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		case 1: /* bold */
		    tcp->attr_mask |= BOLD_ATTR;
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		case 4: /* underline */
		    tcp->attr_mask |= UNDERLINE_ATTR;
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		case 5: /* blink */
		    tcp->attr_mask |= BLINK_ATTR;
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		case 7: /* reverse video */
		    tcp->attr_mask |= REVERSE_ATTR;
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		case 30: case 31: /* set fg color */
		case 32: case 33: case 34:
		case 35: case 36: case 37:
		    tcp->attr_mask |= FG_CHANGED;
		    tcp->cur_color.fg = ansi_col[n - 30];
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		case 40: case 41: /* set bg color */
		case 42: case 43: case 44:
		case 45: case 46: case 47:
		    tcp->attr_mask |= BG_CHANGED;
		    tcp->cur_color.bg = ansi_col[n - 40];
		    tcp->cur_attr = mask2attr(tcp);
		    break;
		}
	    }
	    break;

	case 's':   /* Save cursor position */
	    tcp->saved_xpos = scp->xpos;
	    tcp->saved_ypos = scp->ypos;
	    break;

	case 'u':   /* Restore saved cursor position */
	    if (tcp->saved_xpos >= 0 && tcp->saved_ypos >= 0)
		sc_move_cursor(scp, tcp->saved_xpos, tcp->saved_ypos);
	    break;

	case 'x':
	    if (tcp->num_param == 0)
		n = 0;
	    else
		n = tcp->param[0];
	    switch (n) {
	    case 0:     /* reset attributes */
		tcp->attr_mask = NORMAL_ATTR;
		tcp->cur_color = tcp->std_color = tcp->dflt_std_color;
		tcp->rev_color = tcp->dflt_rev_color;
		tcp->cur_attr = mask2attr(tcp);
		break;
	    case 1:     /* set ansi background */
		tcp->attr_mask &= ~BG_CHANGED;
		tcp->cur_color.bg = tcp->std_color.bg =
		    ansi_col[tcp->param[1] & 0x0f];
		tcp->cur_attr = mask2attr(tcp);
		break;
	    case 2:     /* set ansi foreground */
		tcp->attr_mask &= ~FG_CHANGED;
		tcp->cur_color.fg = tcp->std_color.fg =
		    ansi_col[tcp->param[1] & 0x0f];
		tcp->cur_attr = mask2attr(tcp);
		break;
	    case 3:     /* set ansi attribute directly */
		tcp->attr_mask &= ~(FG_CHANGED | BG_CHANGED);
		tcp->cur_color.fg = tcp->std_color.fg =
		    tcp->param[1] & 0x0f;
		tcp->cur_color.bg = tcp->std_color.bg =
		    (tcp->param[1] >> 4) & 0x0f;
		tcp->cur_attr = mask2attr(tcp);
		break;
	    case 5:     /* set ansi reverse video background */
		tcp->rev_color.bg = ansi_col[tcp->param[1] & 0x0f];
		tcp->cur_attr = mask2attr(tcp);
		break;
	    case 6:     /* set ansi reverse video foreground */
		tcp->rev_color.fg = ansi_col[tcp->param[1] & 0x0f];
		tcp->cur_attr = mask2attr(tcp);
		break;
	    case 7:     /* set ansi reverse video directly */
		tcp->rev_color.fg = tcp->param[1] & 0x0f;
		tcp->rev_color.bg = (tcp->param[1] >> 4) & 0x0f;
		tcp->cur_attr = mask2attr(tcp);
		break;
	    }
	    break;

	case 'z':   /* switch to (virtual) console n */
	    if (tcp->num_param == 1)
		sc_switch_scr(sc, tcp->param[0]);
	    break;
	}
    }
    else if (tcp->esc == 3) {	/* seen ESC [0-9]+ = */