Document pager(1).
This commit is contained in:
parent
ac37d66a93
commit
606385b663
3 changed files with 55 additions and 24 deletions
|
@ -76,6 +76,7 @@ xinstall
|
||||||
MANPAGES=\
|
MANPAGES=\
|
||||||
chkblayout.1 \
|
chkblayout.1 \
|
||||||
kernelinfo.1 \
|
kernelinfo.1 \
|
||||||
|
pager.1 \
|
||||||
passwd.1 \
|
passwd.1 \
|
||||||
readlink.1 \
|
readlink.1 \
|
||||||
|
|
||||||
|
|
51
utils/pager.1
Normal file
51
utils/pager.1
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
.Dd October 05, 2016
|
||||||
|
.Dt PAGER 1
|
||||||
|
.Os
|
||||||
|
.Sh NAME
|
||||||
|
.Nm pager
|
||||||
|
.Nd display files one page at a time
|
||||||
|
.Sh SYNOPSIS
|
||||||
|
.Nm
|
||||||
|
.Op Fl Rr
|
||||||
|
.Ar file ...
|
||||||
|
.Sh DESCRIPTION
|
||||||
|
.Nm
|
||||||
|
displays the input one page at a time. The input is the concatenation of the
|
||||||
|
input files, or the standard input if no files were specified and the
|
||||||
|
standard input is not a terminal.
|
||||||
|
.Pp
|
||||||
|
The options are as follows:
|
||||||
|
.Bl -tag -width "12345678"
|
||||||
|
.It Fl R
|
||||||
|
Output only escape sequences that change font properties such as color and
|
||||||
|
boldness.
|
||||||
|
.It Fl r
|
||||||
|
Causes raw control characters to be dumped directly onto the terminal. Usage
|
||||||
|
of this option may cause output to be misleading for suspicious files, as the
|
||||||
|
escape codes in the file are rendered and can be used to hide parts of the
|
||||||
|
input. Avoid the -r option if you want to see the actual bytes in the file,
|
||||||
|
or use -R to show only selected escape codes.
|
||||||
|
.Sh COMMANDS
|
||||||
|
.Nm
|
||||||
|
supports the following key commands:
|
||||||
|
.Bl -tag -width "12345678"
|
||||||
|
.It Enter or Down Arrow
|
||||||
|
Scroll the file one line down.
|
||||||
|
.It Up Arrow
|
||||||
|
Scroll the file one line up.
|
||||||
|
.It Space or Page Down
|
||||||
|
Scroll the file one page down.
|
||||||
|
.It Page Up
|
||||||
|
Scroll the file one page up.
|
||||||
|
.It End
|
||||||
|
Scroll all the way down to the end of the file.
|
||||||
|
.It Home
|
||||||
|
Scroll all the way up to the beginning of the file.
|
||||||
|
.It q or Q
|
||||||
|
Exit the pager.
|
||||||
|
.El
|
||||||
|
.Sh EXIT STATUS
|
||||||
|
.Nm
|
||||||
|
will exit 0 on success and non-zero otherwise.
|
||||||
|
.Sh SEE ALSO
|
||||||
|
.Xr editor 1
|
|
@ -21,6 +21,7 @@
|
||||||
#include <sys/termmode.h>
|
#include <sys/termmode.h>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <error.h>
|
#include <error.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -604,17 +605,6 @@ static void compact_arguments(int* argc, char*** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void help(FILE* fp, const char* argv0)
|
|
||||||
{
|
|
||||||
fprintf(fp, "Usage: %s [OPTION]... [FILES]...\n", argv0);
|
|
||||||
fprintf(fp, "Displays files one page at a time.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void version(FILE* fp, const char* argv0)
|
|
||||||
{
|
|
||||||
fprintf(fp, "%s (Sortix) %s\n", argv0, VERSIONSTR);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
@ -638,7 +628,6 @@ int main(int argc, char* argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* argv0 = argv[0];
|
|
||||||
for ( int i = 1; i < argc; i++ )
|
for ( int i = 1; i < argc; i++ )
|
||||||
{
|
{
|
||||||
const char* arg = argv[i];
|
const char* arg = argv[i];
|
||||||
|
@ -655,21 +644,11 @@ int main(int argc, char* argv[])
|
||||||
case 'r': pager.flag_raw_control_chars = true; break;
|
case 'r': pager.flag_raw_control_chars = true; break;
|
||||||
case 'R': pager.flag_color_sequences = true; break;
|
case 'R': pager.flag_color_sequences = true; break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s: unknown option -- '%c'\n", argv0, c);
|
errx(1, "unknown option -- '%c'", c);
|
||||||
help(stderr, argv0);
|
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( !strcmp(arg, "--help") )
|
|
||||||
help(stdout, argv0), exit(0);
|
|
||||||
else if ( !strcmp(arg, "--version") )
|
|
||||||
version(stdout, argv0), exit(0);
|
|
||||||
else
|
else
|
||||||
{
|
errx(1, "unknown option: %s", arg);
|
||||||
fprintf(stderr, "%s: unknown option: %s\n", argv0, arg);
|
|
||||||
help(stderr, argv0);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
compact_arguments(&argc, &argv);
|
compact_arguments(&argc, &argv);
|
||||||
|
|
Loading…
Reference in a new issue