summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Kaivo <jkk@ung.org>2022-04-18 20:51:56 -0400
committerJakob Kaivo <jkk@ung.org>2022-04-18 20:51:56 -0400
commit05d5a4db2e33ad6940bcb3820591eecbbb85a4cd (patch)
tree5d4b4ad6375675befa42928fe8f27404c4f813ee
parentc76a9e403ab6b0759261b5211a370e8314fb4c94 (diff)
make note of which commands advance to next file at EOF
-rw-r--r--more.c19
1 files changed, 18 insertions, 1 deletions
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 <EOF>", 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;