scroll

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

commit f9a8555e8d14d53c18d558a777794d2182718f42
parent 7e05ee78525d93fb4b3aed2dd5f7ec53f19b8a57
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date:   Tue, 11 Feb 2020 21:32:54 +0100

Simplify logic

Diffstat:
Mscroll.c | 10++++------
1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/scroll.c b/scroll.c @@ -188,10 +188,9 @@ scrollup(void) /* print one page */ for (; rows > ws.ws_row - first;) { - if (TAILQ_PREV(bottom, tailhead, entries) != NULL) - bottom = TAILQ_PREV(bottom, tailhead, entries); - else + if (TAILQ_PREV(bottom, tailhead, entries) == NULL) break; + bottom = TAILQ_PREV(bottom, tailhead, entries); if (--rows > ws.ws_row - first) write(STDOUT_FILENO, bottom->buf, bottom->size); @@ -208,10 +207,9 @@ scrolldown(void) write(STDOUT_FILENO, "\r\n", 2); /* print one page */ for (; rows >= 0;) { - if (TAILQ_PREV(bottom, tailhead, entries) != NULL) - bottom = TAILQ_PREV(bottom, tailhead, entries); - else + if (TAILQ_PREV(bottom, tailhead, entries) == NULL) break; + bottom = TAILQ_PREV(bottom, tailhead, entries); if (--rows > 0) write(STDOUT_FILENO, bottom->buf, bottom->size);