summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-26 21:11:11 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-26 21:11:11 -0400
commitbc26dac6b39d325b2f9acca356d0e5cfebb9c471 (patch)
tree2d5f4314ce74c8a382e875d72c9a25dc30552c45
parent59c73efe2c924d4e142f5411fd40c41910d2116c (diff)
fix garbage at top of file
-rw-r--r--more.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/more.c b/more.c
index abc9101..ffca1cc 100644
--- a/more.c
+++ b/more.c
@@ -234,6 +234,7 @@ static int more_printline(char *s)
int ret = -1;
+ int output = 0;
for (size_t i = 0; s[i] != '\0'; i++) {
enum { NONE, UNDERLINE, BOLD } attr = NONE;
if (more_backspace && s[i + 1] == '\b') {
@@ -250,7 +251,8 @@ static int more_printline(char *s)
}
putchar(s[i]);
- if (i % columns == 0) {
+ output++;
+ if (((output % columns) == columns ) || (s[i] == '\n')) {
ret++;
}
@@ -270,12 +272,9 @@ static int more_printline(char *s)
static void more_refresh(struct more_file *mf)
{
int printed = 0;
- //wmove(more_win, 0, 0);
- for (size_t i = mf->topline; i + printed < mf->topline + more_lines; i++) {
- /* FIXME: account for long lines */
-
- if (more_getline(mf, i) == -1) {
+ for (size_t i = 0; (int)i + printed < more_lines - 1; i++) {
+ if (more_getline(mf, mf->topline + i) == -1) {
break;
}
@@ -307,7 +306,7 @@ static void more_scroll(struct more_file *mf, int count, int multiple)
while (by-- > 0) {
/* FIXME: account for long lines here, too */
- if (more_getline(mf, mf->topline + more_lines) < 0) {
+ if (more_getline(mf, mf->topline + more_lines - 1) < 0) {
break;
}
mf->topline++;