Scrolling needs to use background colour.

This commit is contained in:
nicm
2017-05-12 13:00:56 +00:00
parent 60f7b05c0c
commit 18bab30792
8 changed files with 57 additions and 34 deletions

View File

@ -75,6 +75,9 @@ screen_write_start(struct screen_write_ctx *ctx, struct window_pane *wp,
TAILQ_INIT(&ctx->list[y].items);
ctx->item = xcalloc(1, sizeof *ctx->item);
ctx->scrolled = 0;
ctx->bg = 8;
if (wp != NULL)
snprintf(tmp, sizeof tmp, "pane %%%u", wp->id);
log_debug("%s: size %ux%u, %s", __func__, screen_size_x(ctx->s),
@ -810,15 +813,16 @@ screen_write_cursormove(struct screen_write_ctx *ctx, u_int px, u_int py)
/* Reverse index (up with scroll). */
void
screen_write_reverseindex(struct screen_write_ctx *ctx)
screen_write_reverseindex(struct screen_write_ctx *ctx, u_int bg)
{
struct screen *s = ctx->s;
struct tty_ctx ttyctx;
screen_write_initctx(ctx, &ttyctx);
ttyctx.bg = bg;
if (s->cy == s->rupper)
grid_view_scroll_region_down(s->grid, s->rupper, s->rlower);
grid_view_scroll_region_down(s->grid, s->rupper, s->rlower, bg);
else if (s->cy > 0)
s->cy--;
@ -852,7 +856,7 @@ screen_write_scrollregion(struct screen_write_ctx *ctx, u_int rupper,
/* Line feed. */
void
screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped, u_int bg)
{
struct screen *s = ctx->s;
struct grid *gd = s->grid;
@ -867,8 +871,13 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
log_debug("%s: at %u,%u (region %u-%u)", __func__, s->cx, s->cy,
s->rupper, s->rlower);
if (bg != ctx->bg) {
screen_write_collect_flush(ctx, 1);
ctx->bg = bg;
}
if (s->cy == s->rlower) {
grid_view_scroll_region_up(gd, s->rupper, s->rlower);
grid_view_scroll_region_up(gd, s->rupper, s->rlower, bg);
screen_write_collect_scroll(ctx);
ctx->scrolled++;
} else if (s->cy < screen_size_y(s) - 1)
@ -877,7 +886,7 @@ screen_write_linefeed(struct screen_write_ctx *ctx, int wrapped)
/* Scroll up. */
void
screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines)
screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines, u_int bg)
{
struct screen *s = ctx->s;
struct grid *gd = s->grid;
@ -888,8 +897,13 @@ screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines)
else if (lines > s->rlower - s->rupper + 1)
lines = s->rlower - s->rupper + 1;
if (bg != ctx->bg) {
screen_write_collect_flush(ctx, 1);
ctx->bg = bg;
}
for (i = 0; i < lines; i++) {
grid_view_scroll_region_up(gd, s->rupper, s->rlower);
grid_view_scroll_region_up(gd, s->rupper, s->rlower, bg);
screen_write_collect_scroll(ctx);
}
ctx->scrolled += lines;
@ -1044,9 +1058,12 @@ screen_write_collect_flush(struct screen_write_ctx *ctx, int scroll_only)
screen_write_initctx(ctx, &ttyctx);
ttyctx.num = ctx->scrolled;
ttyctx.bg = ctx->bg;
tty_write(tty_cmd_scrollup, &ttyctx);
}
ctx->scrolled = 0;
ctx->bg = 8;
if (scroll_only)
return;
@ -1141,7 +1158,7 @@ screen_write_collect_add(struct screen_write_ctx *ctx,
if (s->cx > sx - 1) {
log_debug("%s: wrapped at %u,%u", __func__, s->cx, s->cy);
ci->wrapped = 1;
screen_write_linefeed(ctx, 1);
screen_write_linefeed(ctx, 1, 8);
s->cx = 0;
}
@ -1202,7 +1219,7 @@ screen_write_cell(struct screen_write_ctx *ctx, const struct grid_cell *gc)
/* Check this will fit on the current line and wrap if not. */
if ((s->mode & MODE_WRAP) && s->cx > sx - width) {
screen_write_linefeed(ctx, 1);
screen_write_linefeed(ctx, 1, 8);
s->cx = 0;
}