diff options
author | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-12 13:00:57 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@cvs.openbsd.org> | 2017-05-12 13:00:57 +0000 |
commit | 014dd72a1ec4175e1b14aa30e4ec154a99f9ed9d (patch) | |
tree | 024e77adc2c936ee17dc461eaf03b424545e5535 /usr.bin/tmux | |
parent | 88ccc62520203af46adcd9fb14d3093ce7db163f (diff) |
Scrolling needs to use background colour.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r-- | usr.bin/tmux/grid-view.c | 18 | ||||
-rw-r--r-- | usr.bin/tmux/grid.c | 6 | ||||
-rw-r--r-- | usr.bin/tmux/input.c | 13 | ||||
-rw-r--r-- | usr.bin/tmux/screen-write.c | 35 | ||||
-rw-r--r-- | usr.bin/tmux/server-fn.c | 4 | ||||
-rw-r--r-- | usr.bin/tmux/tmux.h | 15 | ||||
-rw-r--r-- | usr.bin/tmux/tty.c | 12 | ||||
-rw-r--r-- | usr.bin/tmux/window-copy.c | 4 |
8 files changed, 65 insertions, 42 deletions
diff --git a/usr.bin/tmux/grid-view.c b/usr.bin/tmux/grid-view.c index 8a30165599c..40ade691966 100644 --- a/usr.bin/tmux/grid-view.c +++ b/usr.bin/tmux/grid-view.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid-view.c,v 1.28 2017/02/16 12:43:08 nicm Exp $ */ +/* $OpenBSD: grid-view.c,v 1.29 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -96,32 +96,34 @@ grid_view_clear(struct grid *gd, u_int px, u_int py, u_int nx, u_int ny, /* Scroll region up. */ void -grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower) +grid_view_scroll_region_up(struct grid *gd, u_int rupper, u_int rlower, + u_int bg) { if (gd->flags & GRID_HISTORY) { - grid_collect_history(gd, 8); + grid_collect_history(gd, bg); if (rupper == 0 && rlower == gd->sy - 1) - grid_scroll_history(gd, 8); + grid_scroll_history(gd, bg); else { rupper = grid_view_y(gd, rupper); rlower = grid_view_y(gd, rlower); - grid_scroll_history_region(gd, rupper, rlower); + grid_scroll_history_region(gd, rupper, rlower, bg); } } else { rupper = grid_view_y(gd, rupper); rlower = grid_view_y(gd, rlower); - grid_move_lines(gd, rupper, rupper + 1, rlower - rupper, 8); + grid_move_lines(gd, rupper, rupper + 1, rlower - rupper, bg); } } /* Scroll region down. */ void -grid_view_scroll_region_down(struct grid *gd, u_int rupper, u_int rlower) +grid_view_scroll_region_down(struct grid *gd, u_int rupper, u_int rlower, + u_int bg) { rupper = grid_view_y(gd, rupper); rlower = grid_view_y(gd, rlower); - grid_move_lines(gd, rupper + 1, rupper, rlower - rupper, 8); + grid_move_lines(gd, rupper + 1, rupper, rlower - rupper, bg); } /* Insert lines. */ diff --git a/usr.bin/tmux/grid.c b/usr.bin/tmux/grid.c index 7e9c3b6ed33..26efbc56163 100644 --- a/usr.bin/tmux/grid.c +++ b/usr.bin/tmux/grid.c @@ -1,4 +1,4 @@ -/* $OpenBSD: grid.c,v 1.70 2017/04/25 18:20:51 nicm Exp $ */ +/* $OpenBSD: grid.c,v 1.71 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2008 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -284,7 +284,7 @@ grid_clear_history(struct grid *gd) /* Scroll a region up, moving the top line into the history. */ void -grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower) +grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower, u_int bg) { struct grid_line *gl_history, *gl_upper, *gl_lower; u_int yy; @@ -309,7 +309,7 @@ grid_scroll_history_region(struct grid *gd, u_int upper, u_int lower) /* Then move the region up and clear the bottom line. */ memmove(gl_upper, gl_upper + 1, (lower - upper) * sizeof *gl_upper); - memset(gl_lower, 0, sizeof *gl_lower); + grid_empty_line(gd, lower, bg); /* Move the history offset down over the line. */ gd->hscrolled++; diff --git a/usr.bin/tmux/input.c b/usr.bin/tmux/input.c index 0543c0c2731..0d2d8eba5e8 100644 --- a/usr.bin/tmux/input.c +++ b/usr.bin/tmux/input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: input.c,v 1.120 2017/05/12 10:50:11 nicm Exp $ */ +/* $OpenBSD: input.c,v 1.121 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1123,7 +1123,7 @@ input_c0_dispatch(struct input_ctx *ictx) case '\012': /* LF */ case '\013': /* VT */ case '\014': /* FF */ - screen_write_linefeed(sctx, 0); + screen_write_linefeed(sctx, 0, ictx->cell.cell.bg); break; case '\015': /* CR */ screen_write_carriagereturn(sctx); @@ -1168,18 +1168,18 @@ input_esc_dispatch(struct input_ctx *ictx) screen_write_reset(sctx); break; case INPUT_ESC_IND: - screen_write_linefeed(sctx, 0); + screen_write_linefeed(sctx, 0, ictx->cell.cell.bg); break; case INPUT_ESC_NEL: screen_write_carriagereturn(sctx); - screen_write_linefeed(sctx, 0); + screen_write_linefeed(sctx, 0, ictx->cell.cell.bg); break; case INPUT_ESC_HTS: if (s->cx < screen_size_x(s)) bit_set(s->tabs, s->cx); break; case INPUT_ESC_RI: - screen_write_reverseindex(sctx); + screen_write_reverseindex(sctx, ictx->cell.cell.bg); break; case INPUT_ESC_DECKPAM: screen_write_mode_set(sctx, MODE_KKEYPAD); @@ -1417,7 +1417,8 @@ input_csi_dispatch(struct input_ctx *ictx) input_csi_dispatch_sm_private(ictx); break; case INPUT_CSI_SU: - screen_write_scrollup(sctx, input_get(ictx, 0, 1, 1)); + screen_write_scrollup(sctx, input_get(ictx, 0, 1, 1), + ictx->cell.cell.bg); break; case INPUT_CSI_TBC: switch (input_get(ictx, 0, 0, 0)) { diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c index d7bfd512378..7130af3a60b 100644 --- a/usr.bin/tmux/screen-write.c +++ b/usr.bin/tmux/screen-write.c @@ -1,4 +1,4 @@ -/* $OpenBSD: screen-write.c,v 1.121 2017/05/12 10:50:11 nicm Exp $ */ +/* $OpenBSD: screen-write.c,v 1.122 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -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; } diff --git a/usr.bin/tmux/server-fn.c b/usr.bin/tmux/server-fn.c index 9397ef848f2..19517535090 100644 --- a/usr.bin/tmux/server-fn.c +++ b/usr.bin/tmux/server-fn.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server-fn.c,v 1.107 2017/04/17 06:40:32 nicm Exp $ */ +/* $OpenBSD: server-fn.c,v 1.108 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -299,7 +299,7 @@ server_destroy_pane(struct window_pane *wp, int notify) screen_write_start(&ctx, wp, &wp->base); screen_write_scrollregion(&ctx, 0, screen_size_y(ctx.s) - 1); screen_write_cursormove(&ctx, 0, screen_size_y(ctx.s) - 1); - screen_write_linefeed(&ctx, 1); + screen_write_linefeed(&ctx, 1, 8); memcpy(&gc, &grid_default_cell, sizeof gc); gc.attr |= GRID_ATTR_BRIGHT; screen_write_puts(&ctx, &gc, "Pane is dead"); diff --git a/usr.bin/tmux/tmux.h b/usr.bin/tmux/tmux.h index 60d402e60c1..3da4ccefc18 100644 --- a/usr.bin/tmux/tmux.h +++ b/usr.bin/tmux/tmux.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tmux.h,v 1.766 2017/05/12 10:50:11 nicm Exp $ */ +/* $OpenBSD: tmux.h,v 1.767 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -672,6 +672,7 @@ struct screen_write_ctx { struct screen_write_collect_item *item; struct screen_write_collect_line *list; u_int scrolled; + u_int bg; u_int cells; u_int written; @@ -1931,7 +1932,7 @@ void grid_destroy(struct grid *); int grid_compare(struct grid *, struct grid *); void grid_collect_history(struct grid *, u_int); void grid_scroll_history(struct grid *, u_int); -void grid_scroll_history_region(struct grid *, u_int, u_int); +void grid_scroll_history_region(struct grid *, u_int, u_int, u_int); void grid_clear_history(struct grid *); const struct grid_line *grid_peek_line(struct grid *, u_int); void grid_get_cell(struct grid *, u_int, u_int, struct grid_cell *); @@ -1956,8 +1957,8 @@ void grid_view_set_cells(struct grid *, u_int, u_int, const struct grid_cell *, const char *, size_t); void grid_view_clear_history(struct grid *, u_int); void grid_view_clear(struct grid *, u_int, u_int, u_int, u_int, u_int); -void grid_view_scroll_region_up(struct grid *, u_int, u_int); -void grid_view_scroll_region_down(struct grid *, u_int, u_int); +void grid_view_scroll_region_up(struct grid *, u_int, u_int, u_int); +void grid_view_scroll_region_down(struct grid *, u_int, u_int, u_int); void grid_view_insert_lines(struct grid *, u_int, u_int, u_int); void grid_view_insert_lines_region(struct grid *, u_int, u_int, u_int, u_int); @@ -2004,10 +2005,10 @@ void screen_write_clearline(struct screen_write_ctx *, u_int); void screen_write_clearendofline(struct screen_write_ctx *, u_int); void screen_write_clearstartofline(struct screen_write_ctx *, u_int); void screen_write_cursormove(struct screen_write_ctx *, u_int, u_int); -void screen_write_reverseindex(struct screen_write_ctx *); +void screen_write_reverseindex(struct screen_write_ctx *, u_int); void screen_write_scrollregion(struct screen_write_ctx *, u_int, u_int); -void screen_write_linefeed(struct screen_write_ctx *, int); -void screen_write_scrollup(struct screen_write_ctx *, u_int); +void screen_write_linefeed(struct screen_write_ctx *, int, u_int); +void screen_write_scrollup(struct screen_write_ctx *, u_int, u_int); void screen_write_carriagereturn(struct screen_write_ctx *); void screen_write_clearendofscreen(struct screen_write_ctx *, u_int); void screen_write_clearstartofscreen(struct screen_write_ctx *, u_int); diff --git a/usr.bin/tmux/tty.c b/usr.bin/tmux/tty.c index d2a79d7be07..a1570a0d008 100644 --- a/usr.bin/tmux/tty.c +++ b/usr.bin/tmux/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.277 2017/05/12 11:19:24 nicm Exp $ */ +/* $OpenBSD: tty.c,v 1.278 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -1141,18 +1141,20 @@ tty_cmd_clearstartofline(struct tty *tty, const struct tty_ctx *ctx) void tty_cmd_reverseindex(struct tty *tty, const struct tty_ctx *ctx) { + struct window_pane *wp = ctx->wp; + if (ctx->ocy != ctx->orupper) return; if (!tty_pane_full_width(tty, ctx) || - tty_fake_bce(tty, ctx->wp, 8) || + tty_fake_bce(tty, wp, 8) || !tty_term_has(tty->term, TTYC_CSR) || !tty_term_has(tty->term, TTYC_RI)) { tty_redraw_region(tty, ctx); return; } - tty_attributes(tty, &grid_default_cell, ctx->wp); + tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_margin_off(tty); @@ -1176,7 +1178,7 @@ tty_cmd_linefeed(struct tty *tty, const struct tty_ctx *ctx) return; } - tty_attributes(tty, &grid_default_cell, wp); + tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_margin_pane(tty, ctx); @@ -1207,7 +1209,7 @@ tty_cmd_scrollup(struct tty *tty, const struct tty_ctx *ctx) return; } - tty_attributes(tty, &grid_default_cell, wp); + tty_default_attributes(tty, wp, ctx->bg); tty_region_pane(tty, ctx, ctx->orupper, ctx->orlower); tty_margin_pane(tty, ctx); diff --git a/usr.bin/tmux/window-copy.c b/usr.bin/tmux/window-copy.c index 1d84314cf4a..339e9d4a7d1 100644 --- a/usr.bin/tmux/window-copy.c +++ b/usr.bin/tmux/window-copy.c @@ -1,4 +1,4 @@ -/* $OpenBSD: window-copy.c,v 1.174 2017/05/12 10:45:38 nicm Exp $ */ +/* $OpenBSD: window-copy.c,v 1.175 2017/05/12 13:00:56 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com> @@ -321,7 +321,7 @@ window_copy_vadd(struct window_pane *wp, const char *fmt, va_list ap) * (so it's on a new line). */ screen_write_carriagereturn(&back_ctx); - screen_write_linefeed(&back_ctx, 0); + screen_write_linefeed(&back_ctx, 0, 8); } else data->backing_written = 1; old_cy = backing->cy; |