Exemplo n.º 1
0
void
sc_remove_mouse_image(scr_stat *scp)
{
    int size;
    int i;

    if (ISGRAPHSC(scp))
	return;

    ++scp->sc->videoio_in_progress;
    (*scp->rndr->draw_mouse)(scp,
			     (scp->mouse_oldpos%scp->xsize + scp->xoff)*8,
			     (scp->mouse_oldpos/scp->xsize + scp->yoff)
				 * scp->font_size,
			     FALSE);
    size = scp->xsize*scp->ysize;
    i = scp->mouse_oldpos;
    mark_for_update(scp, i);
    mark_for_update(scp, i);
    if (i + scp->xsize + 1 < size) {
	mark_for_update(scp, i + scp->xsize + 1);
    } else if (i + scp->xsize < size) {
	mark_for_update(scp, i + scp->xsize);
    } else if (i + 1 < size) {
	mark_for_update(scp, i + 1);
    }
    scp->status &= ~MOUSE_VISIBLE;
    --scp->sc->videoio_in_progress;
}
Exemplo n.º 2
0
void
sc_remove_mouse_image(scr_stat *scp)
{
    int cols, i, rows;

    if (ISGRAPHSC(scp))
	return;

    SC_VIDEO_LOCK(scp->sc);
    (*scp->rndr->draw_mouse)(scp, scp->mouse_oldxpos, scp->mouse_oldypos,
			     FALSE);
    /*
     * To simplify the renderer and ensure undrawing with correct
     * attributes, mark for update a region containing the cursor
     * (usually 2x2 character cells joined by almost a full line o
     * character cells).
     *
     * The renderer should only undraw any pixels outside of the text
     * window (e.g., ones in borders and hardware cursors).
     */
    i = scp->mouse_oldpos;
    mark_for_update(scp, i);
    mark_for_update(scp, i);
    cols = 1 + howmany(10 - 1, scp->font_width); /* up to VGA cursor width 9 */
    cols = imax(cols, 2);	/* in case it is text mode 2x2 char cells */
    cols = imin(cols, scp->xsize - i % scp->xsize);
    rows = 1 + howmany(16 - 1, scp->font_size);	/* up to VGA cursor height 16 */
    rows = imax(rows, 2);	/* don't bother reducing 3 to 2 if text */
    rows = imin(rows, scp->ysize - i / scp->xsize);
    mark_for_update(scp, i + (rows - 1) * scp->xsize + cols - 1);
    scp->status &= ~MOUSE_VISIBLE;
    SC_VIDEO_UNLOCK(scp->sc);
}
Exemplo n.º 3
0
void
sc_remove_mouse_image(scr_stat *scp)
{
    int size;
    int i;

    if (ISGRAPHSC(scp))
	return;

    SC_VIDEO_LOCK(scp->sc);
    (*scp->rndr->draw_mouse)(scp,
			     (scp->mouse_oldpos%scp->xsize + scp->xoff)
			         * scp->font_width,
			     (scp->mouse_oldpos/scp->xsize + scp->yoff)
				 * scp->font_size,
			     FALSE);
    size = scp->xsize*scp->ysize;
    i = scp->mouse_oldpos;
    mark_for_update(scp, i);
    mark_for_update(scp, i);
#ifndef PC98
    if (i + scp->xsize + 1 < size) {
	mark_for_update(scp, i + scp->xsize + 1);
    } else if (i + scp->xsize < size) {
	mark_for_update(scp, i + scp->xsize);
    } else if (i + 1 < size) {
	mark_for_update(scp, i + 1);
    }
#endif /* PC98 */
    scp->status &= ~MOUSE_VISIBLE;
    SC_VIDEO_UNLOCK(scp->sc);
}
Exemplo n.º 4
0
static void
scteken_putchar(void *arg, const teken_pos_t *tp, teken_char_t c,
    const teken_attr_t *a)
{
	scr_stat *scp = arg;
	u_char *map;
	u_char ch;
	vm_offset_t p;
	int cursor, attr;

	attr = scteken_attr(a) << 8;
#ifdef TEKEN_UTF8
	scteken_get_cp437(&c, &attr);
#endif /* TEKEN_UTF8 */
	ch = c;

	map = scp->sc->scr_map;

	cursor = tp->tp_row * scp->xsize + tp->tp_col;
	p = sc_vtb_pointer(&scp->vtb, cursor);
	sc_vtb_putchar(&scp->vtb, p, map[ch], attr);

	mark_for_update(scp, cursor);
	/*
	 * XXX: Why do we need this? Only marking `cursor' should be
	 * enough. Without this line, we get artifacts.
	 */
	mark_for_update(scp, imin(cursor + 1, scp->xsize * scp->ysize - 1));
}
Exemplo n.º 5
0
void
sc_remove_cutmarking(scr_stat *scp)
{
    crit_enter();
    if (scp->mouse_cut_end >= 0) {
	mark_for_update(scp, scp->mouse_cut_start);
	mark_for_update(scp, scp->mouse_cut_end);
    }
    scp->mouse_cut_start = scp->xsize*scp->ysize;
    scp->mouse_cut_end = -1;
    crit_exit();
    scp->status &= ~MOUSE_CUTTING;
}
Exemplo n.º 6
0
void
sc_remove_cutmarking(scr_stat *scp)
{
    int s;

    s = spltty();
    if (scp->mouse_cut_end >= 0) {
	mark_for_update(scp, scp->mouse_cut_start);
	mark_for_update(scp, scp->mouse_cut_end);
    }
    scp->mouse_cut_start = scp->xsize*scp->ysize;
    scp->mouse_cut_end = -1;
    splx(s);
    scp->status &= ~MOUSE_CUTTING;
}
Exemplo n.º 7
0
static void
scteken_fill(void *arg, const teken_rect_t *r, teken_char_t c,
    const teken_attr_t *a)
{
	scr_stat *scp = arg;
	u_char *map;
	u_char ch;
	unsigned int width;
	int attr, row;

	attr = scteken_attr(a) << 8;
#ifdef TEKEN_UTF8
	scteken_get_cp437(&c, &attr);
#endif /* TEKEN_UTF8 */
	ch = c;

	map = scp->sc->scr_map;

	if (r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize) {
		/* Single contiguous region to fill. */
		sc_vtb_erase(&scp->vtb, r->tr_begin.tp_row * scp->xsize,
		    (r->tr_end.tp_row - r->tr_begin.tp_row) * scp->xsize,
		    map[ch], attr);
	} else {
		/* Fill display line by line. */
		width = r->tr_end.tp_col - r->tr_begin.tp_col;

		for (row = r->tr_begin.tp_row; row < r->tr_end.tp_row; row++) {
			sc_vtb_erase(&scp->vtb, r->tr_begin.tp_row *
			    scp->xsize + r->tr_begin.tp_col,
			    width, map[ch], attr);
		}
	}

	/* Mark begin and end positions to be refreshed. */
	mark_for_update(scp,
	    r->tr_begin.tp_row * scp->xsize + r->tr_begin.tp_col);
	mark_for_update(scp,
	    (r->tr_end.tp_row - 1) * scp->xsize + (r->tr_end.tp_col - 1));
	sc_remove_cutmarking(scp);
}
Exemplo n.º 8
0
/* copy a line under the mouse pointer */
static void
mouse_cut_line(scr_stat *scp)
{
    int i;
    int j;

    if (scp->status & MOUSE_VISIBLE) {
	/* remove the current cut mark */
	crit_enter();
	if (scp->mouse_cut_start <= scp->mouse_cut_end) {
	    mark_for_update(scp, scp->mouse_cut_start);
	    mark_for_update(scp, scp->mouse_cut_end);
	} else if (scp->mouse_cut_end >= 0) {
	    mark_for_update(scp, scp->mouse_cut_end);
	    mark_for_update(scp, scp->mouse_cut_start);
	}

	/* mark the entire line */
	scp->mouse_cut_start =
	    (scp->mouse_pos / scp->xsize) * scp->xsize;
	scp->mouse_cut_end = scp->mouse_cut_start + scp->xsize - 1;
	mark_for_update(scp, scp->mouse_cut_start);
	mark_for_update(scp, scp->mouse_cut_end);
	crit_exit();

	/* copy the line into the cut buffer */
	for (i = 0, j = scp->mouse_cut_start; j <= scp->mouse_cut_end; ++j)
	    cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
	cut_buffer[i++] = '\r';
	cut_buffer[i] = '\0';
	scp->status |= MOUSE_CUTTING;
    }
}
Exemplo n.º 9
0
static void
mouse_do_cut(scr_stat *scp, int from, int to)
{
    int blank;
    int i;
    int leadspaces;
    int p;
    int s;

    for (p = from, i = blank = leadspaces = 0; p <= to; ++p) {
	cut_buffer[i] = sc_vtb_getc(&scp->vtb, p);
	/* Be prepared that sc_vtb_getc() can return '\0' */
	if (cut_buffer[i] == '\0')
	    cut_buffer[i] = ' ';
#ifdef SC_CUT_SPACES2TABS
	if (leadspaces != -1) {
	    if (IS_SPACE_CHAR(cut_buffer[i])) {
		leadspaces++;
		/* Check that we are at tabstop position */
		if ((p % scp->xsize) % 8 == 7) {
		    i -= leadspaces - 1;
		    cut_buffer[i] = '\t';
		    leadspaces = 0;
		}
	    } else {
		leadspaces = -1;
	    }
	}
#endif /* SC_CUT_SPACES2TABS */
	/* remember the position of the last non-space char */
	if (!IS_BLANK_CHAR(cut_buffer[i]))
	    blank = i + 1;	/* the first space after the last non-space */
	++i;
	/* trim trailing blank when crossing lines */
	if ((p % scp->xsize) == (scp->xsize - 1)) {
	    cut_buffer[blank++] = '\r';
	    i = blank;
	    leadspaces = 0;
	}
    }
    cut_buffer[i] = '\0';

    /* remove the current marking */
    s = spltty();
    if (scp->mouse_cut_start <= scp->mouse_cut_end) {
	mark_for_update(scp, scp->mouse_cut_start);
	mark_for_update(scp, scp->mouse_cut_end);
    } else if (scp->mouse_cut_end >= 0) {
	mark_for_update(scp, scp->mouse_cut_end);
	mark_for_update(scp, scp->mouse_cut_start);
    }

    /* mark the new region */
    scp->mouse_cut_start = from;
    scp->mouse_cut_end = to;
    mark_for_update(scp, from);
    mark_for_update(scp, to);
    splx(s);
}
Exemplo n.º 10
0
static void
scteken_putchar(void *arg, const teken_pos_t *tp, teken_char_t c,
    const teken_attr_t *a)
{
	scr_stat *scp = arg;
	u_char *map;
	u_char ch;
	vm_offset_t p;
	int cursor, attr;

	/*
	 * No support for printing right hand sides for CJK fullwidth
	 * characters. Simply print a space and assume that the left
	 * hand side describes the entire character.
	 */
	attr = scteken_attr(a) << 8;
	if (a->ta_format & TF_CJK_RIGHT)
		c = ' ';
#ifdef TEKEN_UTF8
	scteken_get_cp437(&c, &attr);
#endif /* TEKEN_UTF8 */
	ch = c;

	map = scp->sc->scr_map;

	cursor = tp->tp_row * scp->xsize + tp->tp_col;
	p = sc_vtb_pointer(&scp->vtb, cursor);
	sc_vtb_putchar(&scp->vtb, p, map[ch], attr);

	mark_for_update(scp, cursor);
	/*
	 * XXX: Why do we need this? Only marking `cursor' should be
	 * enough. Without this line, we get artifacts.
	 */
	mark_for_update(scp, imin(cursor + 1, scp->xsize * scp->ysize - 1));
}
Exemplo n.º 11
0
/* copy a word under the mouse pointer */
static void
mouse_cut_word(scr_stat *scp)
{
    int start;
    int end;
    int sol;
    int eol;
    int c;
    int i;
    int j;

    /*
     * Because we don't have locale information in the kernel,
     * we only distinguish space char and non-space chars.  Punctuation
     * chars, symbols and other regular chars are all treated alike.
     */
    if (scp->status & MOUSE_VISIBLE) {
	/* remove the current cut mark */
	crit_enter();
	if (scp->mouse_cut_start <= scp->mouse_cut_end) {
	    mark_for_update(scp, scp->mouse_cut_start);
	    mark_for_update(scp, scp->mouse_cut_end);
	} else if (scp->mouse_cut_end >= 0) {
	    mark_for_update(scp, scp->mouse_cut_end);
	    mark_for_update(scp, scp->mouse_cut_start);
	}
	scp->mouse_cut_start = scp->xsize*scp->ysize;
	scp->mouse_cut_end = -1;
	crit_exit();

	sol = (scp->mouse_pos / scp->xsize) * scp->xsize;
	eol = sol + scp->xsize;
	c = sc_vtb_getc(&scp->vtb, scp->mouse_pos);
	if (IS_SPACE_CHAR(c)) {
	    /* blank space */
	    for (j = scp->mouse_pos; j >= sol; --j) {
		c = sc_vtb_getc(&scp->vtb, j);
	        if (!IS_SPACE_CHAR(c))
		    break;
	    }
	    start = ++j;
	    for (j = scp->mouse_pos; j < eol; ++j) {
		c = sc_vtb_getc(&scp->vtb, j);
	        if (!IS_SPACE_CHAR(c))
		    break;
	    }
	    end = j - 1;
	} else {
	    /* non-space word */
	    for (j = scp->mouse_pos; j >= sol; --j) {
		c = sc_vtb_getc(&scp->vtb, j);
	        if (IS_SPACE_CHAR(c))
		    break;
	    }
	    start = ++j;
	    for (j = scp->mouse_pos; j < eol; ++j) {
		c = sc_vtb_getc(&scp->vtb, j);
	        if (IS_SPACE_CHAR(c))
		    break;
	    }
	    end = j - 1;
	}

	/* copy the found word */
	for (i = 0, j = start; j <= end; ++j)
	    cut_buffer[i++] = sc_vtb_getc(&scp->vtb, j);
	cut_buffer[i] = '\0';
	scp->status |= MOUSE_CUTTING;

	/* mark the region */
	crit_enter();
	scp->mouse_cut_start = start;
	scp->mouse_cut_end = end;
	mark_for_update(scp, start);
	mark_for_update(scp, end);
	crit_exit();
    }
}
Exemplo n.º 12
0
/* copy marked region to the cut buffer */
static void
mouse_cut(scr_stat *scp)
{
    int start;
    int end;
    int from;
    int to;
    int blank;
    int c;
    int p;
    int i;

    start = scp->mouse_cut_start;
    if (scp->mouse_pos >= start) {
	from = start;
	to = end = scp->mouse_pos;
    } else {
	from = end = scp->mouse_pos;
	to = start - 1;
    }
    for (p = from, i = blank = 0; p <= to; ++p) {
	cut_buffer[i] = sc_vtb_getc(&scp->vtb, p);
	/* remember the position of the last non-space char */
	if (!IS_SPACE_CHAR(cut_buffer[i++]))
	    blank = i;		/* the first space after the last non-space */
	/* trim trailing blank when crossing lines */
	if ((p % scp->xsize) == (scp->xsize - 1)) {
	    cut_buffer[blank] = '\r';
	    i = blank + 1;
	}
    }
    cut_buffer[i] = '\0';

    /* scan towards the end of the last line */
    --p;
    for (i = p % scp->xsize; i < scp->xsize; ++i) {
	c = sc_vtb_getc(&scp->vtb, p);
	if (!IS_SPACE_CHAR(c))
	    break;
	++p;
    }
    /* if there is nothing but blank chars, trim them, but mark towards eol */
    if (i >= scp->xsize) {
	if (end >= start)
	    to = end = p - 1;
	else
	    to = start = p;
	cut_buffer[blank++] = '\r';
	cut_buffer[blank] = '\0';
    }

    /* remove the current marking */
    crit_enter();
    if (scp->mouse_cut_start <= scp->mouse_cut_end) {
	mark_for_update(scp, scp->mouse_cut_start);
	mark_for_update(scp, scp->mouse_cut_end);
    } else if (scp->mouse_cut_end >= 0) {
	mark_for_update(scp, scp->mouse_cut_end);
	mark_for_update(scp, scp->mouse_cut_start);
    }

    /* mark the new region */
    scp->mouse_cut_start = start;
    scp->mouse_cut_end = end;
    mark_for_update(scp, from);
    mark_for_update(scp, to);
    crit_exit();
}
Exemplo n.º 13
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]+ = */
Exemplo n.º 14
0
static void
scteken_copy(void *arg, const teken_rect_t *r, const teken_pos_t *p)
{
	scr_stat *scp = arg;
	unsigned int width;
	int src, dst, end;

#ifndef SC_NO_HISTORY
	/*
	 * We count a line of input as history if we perform a copy of
	 * one whole line upward. In other words: if a line of text gets
	 * overwritten by a rectangle that's right below it.
	 */
	if (scp->history != NULL &&
	    r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize &&
	    r->tr_begin.tp_row == p->tp_row + 1) {
		sc_hist_save_one_line(scp, p->tp_row);
	}
#endif

	if (r->tr_begin.tp_col == 0 && r->tr_end.tp_col == scp->xsize) {
		/* Single contiguous region to copy. */
		sc_vtb_move(&scp->vtb, r->tr_begin.tp_row * scp->xsize,
		    p->tp_row * scp->xsize,
		    (r->tr_end.tp_row - r->tr_begin.tp_row) * scp->xsize);
	} else {
		/* Copy line by line. */
		width = r->tr_end.tp_col - r->tr_begin.tp_col;

		if (p->tp_row < r->tr_begin.tp_row) {
			/* Copy from top to bottom. */
			src = r->tr_begin.tp_row * scp->xsize +
			    r->tr_begin.tp_col;
			end = r->tr_end.tp_row * scp->xsize +
			    r->tr_end.tp_col;
			dst = p->tp_row * scp->xsize + p->tp_col;

			while (src < end) {
				sc_vtb_move(&scp->vtb, src, dst, width);

				src += scp->xsize;
				dst += scp->xsize;
			}
		} else {
			/* Copy from bottom to top. */
			src = (r->tr_end.tp_row - 1) * scp->xsize +
			    r->tr_begin.tp_col;
			end = r->tr_begin.tp_row * scp->xsize +
			    r->tr_begin.tp_col;
			dst = (p->tp_row + r->tr_end.tp_row -
			    r->tr_begin.tp_row - 1) * scp->xsize + p->tp_col;

			while (src >= end) {
				sc_vtb_move(&scp->vtb, src, dst, width);

				src -= scp->xsize;
				dst -= scp->xsize;
			}
		}
	}

	/* Mark begin and end positions to be refreshed. */
	mark_for_update(scp,
	    p->tp_row * scp->xsize + p->tp_col);
	mark_for_update(scp,
	    (p->tp_row + r->tr_end.tp_row - r->tr_begin.tp_row - 1) *
	    scp->xsize +
	    (p->tp_col + r->tr_end.tp_col - r->tr_begin.tp_col - 1));
	sc_remove_cutmarking(scp);
}