scroll

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

commit 66f97243ff888b8cdcd69b57d3abdaf58a070ec9
parent 4ed0bd4aa3382ec3b73693b4379cfa8cc91e0e7e
Author: Jochen Sprickerhof <git@jochen.sprickerhof.de>
Date:   Sun, 12 Apr 2020 22:53:03 +0200

Simplify window fraction logic

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

diff --git a/scroll.c b/scroll.c @@ -296,8 +296,8 @@ scrollup(int n) int rows = 2; struct line *scrollend = bottom; - if (n < 0) - n = ws.ws_row / (-n) > 0 ? ws.ws_row / (-n) : 1; + if (n < 0) /* scroll by fraction of window rows, but at least one line */ + n = ws.ws_row > (-n) ? ws.ws_row / (-n) : 1; /* wind back scrollend pointer by one page plus n */ for (; scrollend != NULL && TAILQ_NEXT(scrollend, entries) != NULL && @@ -338,8 +338,8 @@ scrolldown(char *buf, size_t size, int n) if (bottom == NULL || bottom == TAILQ_FIRST(&head)) return; - if (n < 0) - n = ws.ws_row / (-n) > 0 ? ws.ws_row / (-n) : 1; + if (n < 0) /* scroll by fraction of window rows, but at least one line */ + n = ws.ws_row > (-n) ? ws.ws_row / (-n) : 1; bottom = TAILQ_PREV(bottom, tailhead, entries); /* print n lines */