From 886d50dcabf98d7469d982241336593acbb2e6f6 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 12 May 2017 10:50:11 +0000 Subject: ECH needs to use background colour. --- tty.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index 18e4c3d2..e182be22 100644 --- a/tty.c +++ b/tty.c @@ -798,6 +798,7 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py, u_int ny, u_int px, u_int nx, u_int bg) { u_int yy; + char tmp[64]; log_debug("%s: %u,%u at %u,%u", __func__, nx, ny, px, py); @@ -815,6 +816,17 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py, tty_putcode(tty, TTYC_ED); return; } + + /* + * If we're setting a background colour (so it is not default), + * we can use DECFRA. + */ + if (tty->term_type == TTY_VT420 && bg != 8) { + xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x", + py + 1, px + 1, py + ny, px + nx); + tty_puts(tty, tmp); + return; + } } /* Couldn't use an escape sequence, loop over the lines. */ @@ -1023,7 +1035,7 @@ tty_cmd_deletecharacter(struct tty *tty, const struct tty_ctx *ctx) void tty_cmd_clearcharacter(struct tty *tty, const struct tty_ctx *ctx) { - tty_attributes(tty, &grid_default_cell, ctx->wp); + tty_default_attributes(tty, ctx->wp, ctx->bg); tty_cursor_pane(tty, ctx, ctx->ocx, ctx->ocy); -- cgit From 7f626c89595abd5dae6716d6b6e21ea96e22a856 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 12 May 2017 11:13:43 +0000 Subject: Can use INDN to clear regions with default background colour if margins are supported. --- tty.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index e182be22..720eb417 100644 --- a/tty.c +++ b/tty.c @@ -808,6 +808,7 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py, /* If genuine BCE is available, can try escape sequences. */ if (!tty_fake_bce(tty, wp, bg)) { + /* Use ED if clearing off the bottom of the terminal. */ if (px == 0 && px + nx >= tty->sx && py + ny >= tty->sy && @@ -818,8 +819,9 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py, } /* - * If we're setting a background colour (so it is not default), - * we can use DECFRA. + * On VT420 compatible terminals we can use DECFRA if the + * background colour isn't default (because it doesn't work + * after SGR 0). */ if (tty->term_type == TTY_VT420 && bg != 8) { xsnprintf(tmp, sizeof tmp, "\033[32;%u;%u;%u;%u$x", @@ -827,6 +829,17 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py, tty_puts(tty, tmp); return; } + + /* + * If margins are supported, can just scroll the area off to + * clear it. + */ + if (tty_use_margin(tty) && tty_term_has(tty->term, TTYC_INDN)) { + tty_region(tty, py, py + ny - 1); + tty_margin(tty, px, px + nx - 1); + tty_putcode1(tty, TTYC_INDN, ny); + return; + } } /* Couldn't use an escape sequence, loop over the lines. */ -- cgit From 60f7b05c0c9fbee371dac86229d888aed7b0e7f6 Mon Sep 17 00:00:00 2001 From: nicm Date: Fri, 12 May 2017 11:19:24 +0000 Subject: Regions can't be smaller than 2 so don't try to clear them by scrolling if so. --- tty.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'tty.c') diff --git a/tty.c b/tty.c index 720eb417..00460574 100644 --- a/tty.c +++ b/tty.c @@ -834,7 +834,10 @@ tty_clear_area(struct tty *tty, const struct window_pane *wp, u_int py, * If margins are supported, can just scroll the area off to * clear it. */ - if (tty_use_margin(tty) && tty_term_has(tty->term, TTYC_INDN)) { + if (nx > 2 && + ny > 2 && + tty_use_margin(tty) && + tty_term_has(tty->term, TTYC_INDN)) { tty_region(tty, py, py + ny - 1); tty_margin(tty, px, px + nx - 1); tty_putcode1(tty, TTYC_INDN, ny); -- cgit