Only move bottom if it was scrolled out of the window - scroll - scrollbackbuff… | |
git clone git://git.suckless.org/scroll | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 4b23d03e3c8dcac58d48fc89c1bc84f5ce27b718 | |
parent 97b90414891e957c95caffe078c69b18aa38e659 | |
Author: Jochen Sprickerhof <[email protected]> | |
Date: Fri, 17 Apr 2020 22:47:19 +0200 | |
Only move bottom if it was scrolled out of the window | |
Diffstat: | |
M scroll.c | 12 +++++++++--- | |
1 file changed, 9 insertions(+), 3 deletions(-) | |
--- | |
diff --git a/scroll.c b/scroll.c | |
@@ -314,16 +314,22 @@ scrollup(int n) | |
write(STDOUT_FILENO, scrollend->buf + 1, scrollend->size - 1); | |
else | |
write(STDOUT_FILENO, scrollend->buf, scrollend->size); | |
- bottom = TAILQ_NEXT(bottom, entries); | |
+ 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); | |
- bottom = TAILQ_NEXT(bottom, entries); | |
+ if ( x + n >= ws.ws_row) | |
+ bottom = TAILQ_NEXT(bottom, entries); | |
write(STDOUT_FILENO, scrollend->buf, scrollend->size); | |
} | |
/* move cursor from line n to the old bottom position */ | |
- dprintf(STDOUT_FILENO, "\033[%d;0H", x); | |
+ if (x + n < ws.ws_row) { | |
+ dprintf(STDOUT_FILENO, "\033[%d;%dH", x + n, y); | |
+ write(STDOUT_FILENO, "\033[?25h", 6); /* show cursor */ | |
+ } else | |
+ dprintf(STDOUT_FILENO, "\033[%d;0H", ws.ws_row); | |
} | |
void |