From 5a5dbecec1723ec67357da4c174f600728933859 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Tue, 19 Apr 2022 20:45:18 -0400 Subject: get closer to fixing long line issues --- more.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/more.c b/more.c index 11d2454..6e941fc 100644 --- a/more.c +++ b/more.c @@ -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); } -- cgit v1.2.1