commit 66f97243ff888b8cdcd69b57d3abdaf58a070ec9
Author:     Jochen Sprickerhof <[email protected]>
AuthorDate: Sun Apr 12 22:53:03 2020 +0200
Commit:     Jochen Sprickerhof <[email protected]>
CommitDate: Sun Apr 12 22:54:01 2020 +0200

    Simplify window fraction logic

diff --git a/scroll.c b/scroll.c
index bbfff7d..c35e7bc 100644
--- 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 */

Reply via email to