scroll

scrollbackbuffer program for st
git clone git://git.suckless.org/scroll
Log | Files | Refs | README

commit 79dd01d2f78326259f1dbdb3d4d124b94f7bcd8b
parent 5cfe13ab217d60cbfcdb6d7f5e60f5c290e5e3d1
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date:   Sun,  5 Apr 2020 22:06:16 +0200

Fix some special cases in scrolling

Diffstat:
Mscroll.c | 7+++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scroll.c b/scroll.c @@ -283,21 +283,24 @@ scrollup(int n) bottom = TAILQ_NEXT(bottom, entries); write(STDOUT_FILENO, scrollend->buf, scrollend->size); } + dprintf(STDOUT_FILENO, "\033[%d;%dH", ws.ws_row, ws.ws_col); } void scrolldown(char *buf, size_t size, int n) { + if (bottom == NULL || bottom == TAILQ_FIRST(&head)) + return; bottom = TAILQ_PREV(bottom, tailhead, entries); /* print n lines */ for (; n > 0 && bottom != NULL && bottom != TAILQ_FIRST(&head); n--) { bottom = TAILQ_PREV(bottom, tailhead, entries); write(STDOUT_FILENO, bottom->buf, bottom->size); } - if (bottom == TAILQ_FIRST(&head)) { + if (n > 0 && bottom == TAILQ_FIRST(&head)) { write(STDOUT_FILENO, "\033[?25h", 6); /* show cursor */ write(STDOUT_FILENO, buf, size); - } else + } else if (bottom != NULL) bottom = TAILQ_NEXT(bottom, entries); }