commit 0f993a9704c131c24df73154454b3b2ced84f585
parent f428ba14194dbe1f143bcc31dc7b3ef9f072db08
Author: Jan Klemkow <j.klemkow@wemelug.de>
Date: Sat, 8 Feb 2020 02:38:30 +0100
fix scrollback behavior
1. /r/n of the last printed line must no printed,
to avoid an additional empty line
2. the input line on the bottom of the terminal
have to be substracted from the first scroll
back jump.
Diffstat:
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/scroll.c b/scroll.c
@@ -165,6 +165,7 @@ void
scrollup(void)
{
int rows;
+ int first = 0;
/* move the text in terminal n lines down */
dprintf(STDOUT_FILENO, "\033[%dS", ws.ws_row);
@@ -172,12 +173,19 @@ scrollup(void)
/* set cursor position */
write(STDOUT_FILENO, "\033[0;0H", 6);
+ if (TAILQ_FIRST(&head) == bottom)
+ first = 1;
+
for (rows = 0; bottom != NULL && rows < 2 * ws.ws_row; rows++)
bottom = TAILQ_NEXT(bottom, entries);
- for (; bottom != NULL && rows > ws.ws_row; rows--) {
- bottom = TAILQ_PREV(bottom, tailhead, entries);
- write(STDOUT_FILENO, bottom->buf, bottom->len);
+ for (; rows > ws.ws_row - first;) {
+ if ((bottom = TAILQ_PREV(bottom, tailhead, entries)) == NULL)
+ break;
+ if (--rows > ws.ws_row - first)
+ write(STDOUT_FILENO, bottom->buf, bottom->size);
+ else /* last line w/o "/r/n" */
+ write(STDOUT_FILENO, bottom->buf, bottom->size - 2);
}
}