summaryrefslogtreecommitdiff
path: root/more.c
diff options
context:
space:
mode:
Diffstat (limited to 'more.c')
-rw-r--r--more.c40
1 files changed, 26 insertions, 14 deletions
diff --git a/more.c b/more.c
index 8028263..08aea79 100644
--- a/more.c
+++ b/more.c
@@ -14,10 +14,24 @@
#include <unistd.h>
#include <wordexp.h>
-#include "more.h"
+struct more_file {
+ struct more_file *next;
+ struct more_file *prev;
+ FILE *f;
+ FILE *backing;
+ size_t topline;
+ fpos_t *tlines;
+ size_t nlines;
+ size_t mark[26];
+ size_t nbytes;
+ size_t *bytepos;
+ char *buf;
+ size_t nbuf;
+ char *path;
+};
-static int more_clear = 0;
static int retval = 0;
+static int more_clear = 0;
static WINDOW *more_win = NULL;
static WINDOW *more_status = NULL;
@@ -32,7 +46,7 @@ enum {
static int more(const char *);
-ssize_t more_getline(struct more_file *mf, size_t lineno)
+static ssize_t more_getline(struct more_file *mf, size_t lineno)
{
if (mf->nlines <= lineno && mf->nlines != 0) {
fsetpos(mf->f, &(mf->tlines[mf->nlines - 1]));
@@ -66,7 +80,7 @@ ssize_t more_getline(struct more_file *mf, size_t lineno)
return getline(&(mf->buf), &(mf->nbuf), mf->backing);
}
-struct more_file more_open(const char *path)
+static struct more_file more_open(const char *path)
{
struct more_file mf = {
.f = stdin,
@@ -94,7 +108,7 @@ struct more_file more_open(const char *path)
return mf;
}
-void more_close(struct more_file *mf)
+static void more_close(struct more_file *mf)
{
if (mf->backing != mf->f) {
fclose(mf->backing);
@@ -126,7 +140,7 @@ static void more_scroll(struct more_file *mf, int count, int multiple)
{
int by = count ? count * multiple : multiple;
- if (abs(by) >= LINES && more_clear) {
+ if (more_clear) {
clear();
}
@@ -195,12 +209,10 @@ static void more_help(void)
fprintf(f, "\n");
fprintf(f, "Scrolling Commands: Prefix with a count for number of lines, otherwise as shown\n");
- fprintf(f, "f ^F forward one screen\n");
- fprintf(f, "b ^B backward one screen\n");
- fprintf(f, "j <space> <newline> forward one line\n");
- fprintf(f, "k backward one line\n");
- fprintf(f, "d ^D forward one half screen\n");
- fprintf(f, "u ^U backward one half screen\n");
+ fprintf(f, "%-20s%-30s%-10s\n", " ", "forward", "backward");
+ fprintf(f, "%-20s%-30s%-10s\n", "one line", "j <space> <newline>", "k");
+ fprintf(f, "%-20s%-30s%-10s\n", "one half screen", "d ^D", "u ^U");
+ fprintf(f, "%-20s%-30s%-10s\n", "one screen", "f ^F", "b ^B");
fprintf(f, "\n");
fprintf(f, "Jumping Commands\n");
@@ -680,13 +692,13 @@ int main(int argc, char *argv[])
cbreak();
noecho();
+ atexit(more_exit);
+
more_win = newwin(LINES - 1, 0, 0, 0);
scrollok(more_win, TRUE);
more_status = newwin(1, 0, LINES - 1, 0);
touchwin(stdscr);
- atexit(more_exit);
-
if (more_clear) {
clear();
}