commit 56040e62d3d7deb9334732ab4472aba9c0f1a95b
parent 2ffcf5b56b8bb813f96717c9b0262d772b766636
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date: Tue, 11 Feb 2020 20:18:15 +0100
Add scrolldown
Diffstat:
1 file changed, 19 insertions(+), 0 deletions(-)
diff --git a/scroll.c b/scroll.c
@@ -197,6 +197,23 @@ scrollup(void)
}
}
+void
+scrolldown(void)
+{
+ int rows = ws.ws_row;
+
+ write(STDOUT_FILENO, "\r\n", 2);
+ /* print one page */
+ for (; rows >= 0;) {
+ if ((bottom = TAILQ_PREV(bottom, tailhead, entries)) == NULL)
+ break;
+ if (--rows > 0)
+ write(STDOUT_FILENO, bottom->buf, bottom->size);
+ else /* last line w/o "/r/n" */
+ write(STDOUT_FILENO, bottom->buf, bottom->size - 2);
+ }
+}
+
int
main(int argc, char *argv[])
{
@@ -271,6 +288,8 @@ main(int argc, char *argv[])
die("read:");
if (c == 17) /* ^Q */
scrollup();
+ else if (c == 18) /* ^R */
+ scrolldown();
else if (write(mfd, &c, 1) == -1)
die("write:");
}