[hackers] [scroll] Cleanup || Jochen Sprickerhof
commit ef64e7624c591d601da56c52948be37b1f54f18c
Author: Jochen Sprickerhof <git_AT_jochen.sprickerhof.de>
AuthorDate: Mon Apr 20 23:22:27 2020 +0200
Commit: Jochen Sprickerhof <git_AT_jochen.sprickerhof.de>
CommitDate: Mon Apr 20 23:22:36 2020 +0200
Cleanup
diff --git a/scroll.c b/scroll.c
index 22e2970..a6a1e52 100644
--- a/scroll.c
+++ b/scroll.c
_AT_@ -291,19 +291,22 @@ scrollup(int n)
int rows = 2, x, y;
struct line *scrollend = bottom;
+ if (bottom == NULL)
+ return;
+
getcursorposition(&x, &y);
if (n < 0) /* scroll by fraction of ws.ws_row, 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 &&
+ for (; TAILQ_NEXT(scrollend, entries) != NULL &&
rows < x + n; rows++)
scrollend = TAILQ_NEXT(scrollend, entries);
rows -= x;
- if (scrollend == NULL || rows <= 0)
+ if (rows <= 0)
return;
/* move the text in terminal rows lines down */
_AT_@ -318,13 +321,13 @@ scrollup(int n)
write(STDOUT_FILENO, scrollend->buf + 1, scrollend->size - 1);
else
write(STDOUT_FILENO, scrollend->buf, scrollend->size);
- if ( x + n >= ws.ws_row)
+ if (x + n >= ws.ws_row)
bottom = TAILQ_NEXT(bottom, entries);
/* print rows lines and move bottom forward to the new screen bottom */
for (; rows > 1; rows--) {
scrollend = TAILQ_PREV(scrollend, tailhead, entries);
- if ( x + n >= ws.ws_row)
+ if (x + n >= ws.ws_row)
bottom = TAILQ_NEXT(bottom, entries);
write(STDOUT_FILENO, scrollend->buf, scrollend->size);
}
Received on Tue Apr 21 2020 - 09:17:05 CEST
This archive was generated by hypermail 2.3.0
: Tue Apr 21 2020 - 09:24:37 CEST