From 05d5a4db2e33ad6940bcb3820591eecbbb85a4cd Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 18 Apr 2022 20:51:56 -0400 Subject: make note of which commands advance to next file at EOF --- more.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/more.c b/more.c index b126c35..46afaa9 100644 --- a/more.c +++ b/more.c @@ -31,7 +31,7 @@ enum { static void more_refresh(struct more_file *mf) { - for (size_t i = mf->topline; i < mf->topline + LINES; i++) { + for (size_t i = mf->topline; i < mf->topline + LINES - 1; i++) { /* FIXME: account for long lines */ if (more_getline(mf, i) == -1) { @@ -189,7 +189,11 @@ static int more(const char *path) int count = 0; while (mf.f) { + int at_eof = 0; //(mf.topline + LINES >= mf.nlines); wmove(more_status, 0, 0); + if (at_eof) { + wprintw(more_status, "%s ", mf.path); + } int c = wgetch(more_status); wclear(more_status); @@ -205,6 +209,10 @@ static int more(const char *path) case 'f': case CTRL_F: + if (at_eof) { + return 1; + } + if (count == 0) { count = LINES - 1; } @@ -224,6 +232,9 @@ static int more(const char *path) /* FALLTHRU */ case 'j': case '\n': + if (at_eof) { + return 1; + } more_scroll(&mf, count, 1); break; @@ -233,10 +244,16 @@ static int more(const char *path) case 'd': case CTRL_D: + if (at_eof) { + return 1; + } more_scroll(&mf, count, (LINES - 1) / 2); break; case 's': + if (at_eof) { + return 1; + } count = count ? count : 1; more_scroll(&mf, LINES - 1 + count, 1); break; -- cgit v1.2.1