diff options
Diffstat (limited to 'more.c')
-rw-r--r-- | more.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -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++; |