diff options
| -rw-r--r-- | more.c | 26 |
1 files changed, 24 insertions, 2 deletions
@@ -144,16 +144,38 @@ static void more_close(struct more_file *mf) free(mf->buf); } +static int more_printline(char *s) +{ + int ret = -1; + /* + if (strlen(s) == (size_t)COLS) { + s[COLS - 1] = '\0'; + } + */ + + scrollok(more_win, FALSE); + for (size_t i = 0; s[i] != '\0'; i++) { + waddch(more_win, s[i]); + if (i % COLS == 0) { + ret++; + } + } + scrollok(more_win, TRUE); + + return ret; +} + static void more_refresh(struct more_file *mf) { - for (size_t i = mf->topline; i < mf->topline + LINES; i++) { + int printed = 0; + for (size_t i = 0; i + printed < mf->topline + LINES; i++) { /* FIXME: account for long lines */ if (more_getline(mf, i) == -1) { break; } - wprintw(more_win, "%s", mf->buf); + printed += more_printline(mf->buf); } wrefresh(more_win); } |
