=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/screen-write.c,v retrieving revision 1.109 retrieving revision 1.110 diff -c -r1.109 -r1.110 *** src/usr.bin/tmux/screen-write.c 2017/02/08 16:45:18 1.109 --- src/usr.bin/tmux/screen-write.c 2017/02/08 17:31:09 1.110 *************** *** 1,4 **** ! /* $OpenBSD: screen-write.c,v 1.109 2017/02/08 16:45:18 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: screen-write.c,v 1.110 2017/02/08 17:31:09 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott *************** *** 839,844 **** --- 839,846 ---- if (rupper >= rlower) /* cannot be one line */ return; + screen_write_collect_flush(ctx); + /* Cursor moves to top-left. */ s->cx = 0; s->cy = 0; *************** *** 854,860 **** struct screen *s = ctx->s; struct grid *gd = s->grid; struct grid_line *gl; - struct tty_ctx ttyctx; gl = &gd->linedata[gd->hsize + s->cy]; if (wrapped) --- 856,861 ---- *************** *** 864,877 **** if (s->cy == s->rlower) { grid_view_scroll_region_up(gd, s->rupper, s->rlower); - screen_write_collect_scroll(ctx); ! screen_write_initctx(ctx, &ttyctx); ! tty_write(tty_cmd_linefeed, &ttyctx); } else if (s->cy < screen_size_y(s) - 1) s->cy++; } /* Carriage return (cursor to start of line). */ void screen_write_carriagereturn(struct screen_write_ctx *ctx) --- 865,896 ---- if (s->cy == s->rlower) { grid_view_scroll_region_up(gd, s->rupper, s->rlower); screen_write_collect_scroll(ctx); ! ctx->scrolled++; } else if (s->cy < screen_size_y(s) - 1) s->cy++; } + /* Scroll up. */ + void + screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines) + { + struct screen *s = ctx->s; + struct grid *gd = s->grid; + u_int i; + + if (lines == 0) + lines = 1; + else if (lines > s->rlower - s->rupper + 1) + lines = s->rlower - s->rupper + 1; + + for (i = 0; i < lines; i++) { + grid_view_scroll_region_up(gd, s->rupper, s->rlower); + screen_write_collect_scroll(ctx); + } + ctx->scrolled += lines; + } + /* Carriage return (cursor to start of line). */ void screen_write_carriagereturn(struct screen_write_ctx *ctx) *************** *** 1008,1013 **** --- 1027,1044 ---- struct screen_write_collect_item *ci, *tmp; u_int y, cx, cy; struct tty_ctx ttyctx; + + if (ctx->scrolled != 0) { + log_debug("%s: scrolled %u (region %u-%u)", __func__, + ctx->scrolled, s->rupper, s->rlower); + if (ctx->scrolled > s->rlower - s->rupper + 1) + ctx->scrolled = s->rlower - s->rupper + 1; + + screen_write_initctx(ctx, &ttyctx); + ttyctx.num = ctx->scrolled; + tty_write(tty_cmd_scrollup, &ttyctx); + } + ctx->scrolled = 0; cx = s->cx; cy = s->cy; for (y = 0; y < screen_size_y(s); y++) {