summaryrefslogtreecommitdiffstats
path: root/usr.bin/tmux/screen-write.c
diff options
context:
space:
mode:
authornicm <nicm@openbsd.org>2019-08-05 06:42:02 +0000
committernicm <nicm@openbsd.org>2019-08-05 06:42:02 +0000
commitfa32c33cb2c940fdf5a9d0692815170e0597af5f (patch)
treed447f85d67802ac6e46f4cae24fc0f2fd347a34c /usr.bin/tmux/screen-write.c
parentXr pf 4 (diff)
downloadwireguard-openbsd-fa32c33cb2c940fdf5a9d0692815170e0597af5f.tar.xz
wireguard-openbsd-fa32c33cb2c940fdf5a9d0692815170e0597af5f.zip
Add support for the SD (scroll down) escape sequence, GitHub issue 1861.
Diffstat (limited to 'usr.bin/tmux/screen-write.c')
-rw-r--r--usr.bin/tmux/screen-write.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/usr.bin/tmux/screen-write.c b/usr.bin/tmux/screen-write.c
index 0a8d6665755..7e169c21c2d 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.156 2019/07/08 11:38:14 nicm Exp $ */
+/* $OpenBSD: screen-write.c,v 1.157 2019/08/05 06:42:02 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -1088,6 +1088,31 @@ screen_write_scrollup(struct screen_write_ctx *ctx, u_int lines, u_int bg)
ctx->scrolled += lines;
}
+/* Scroll down. */
+void
+screen_write_scrolldown(struct screen_write_ctx *ctx, u_int lines, u_int bg)
+{
+ struct screen *s = ctx->s;
+ struct grid *gd = s->grid;
+ struct tty_ctx ttyctx;
+ u_int i;
+
+ screen_write_initctx(ctx, &ttyctx);
+ ttyctx.bg = bg;
+
+ 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_down(gd, s->rupper, s->rlower, bg);
+
+ screen_write_collect_flush(ctx, 0);
+ ttyctx.num = lines;
+ tty_write(tty_cmd_scrolldown, &ttyctx);
+}
+
/* Carriage return (cursor to start of line). */
void
screen_write_carriagereturn(struct screen_write_ctx *ctx)