mscan: spawn a pager for interactive use

pull/22/merge
Leah Neukirchen 7 years ago
parent e8107b1889
commit 94854ad185

@ -25,6 +25,7 @@ maddr magrep mexport mflag mgenmid mhdr mlist mpick mscan msed mseq mshow msort
maddr magrep mhdr mpick mscan mshow : rfc2047.o
magrep mshow : rfc2045.o
mshow : filter.o safe_u8putstr.o rfc2231.o pipeto.o
mscan : pipeto.o
msort : mystrverscmp.o
mmime : slurp.o

@ -22,7 +22,8 @@ If no
are passed,
.Nm
reads file names from standard input,
or uses the mails in the current sequence when used interactively.
or uses the mails in the current sequence when used interactively
(using a pager).
.Pp
By default,
.Ar format
@ -166,6 +167,17 @@ You are in
You are in
.Sq Li "Resent-To:" .
.El
.Sh ENVIRONMENT
.Bl -tag -width MBLAZE_PAGER
.It Ev MBLAZE_PAGER
Any non-empty value of the environment variable
.Ev MBLAZE_PAGER
is used instead of the standard pagination program, specified in
.Ev PAGER .
When empty or set to
.Sq Ic cat ,
no pager is spawned.
.El
.Sh EXIT STATUS
.Ex -std
.Sh SEE ALSO

@ -488,6 +488,8 @@ oneline(char *file)
int
main(int argc, char *argv[])
{
pid_t pid1 = -1;
int c;
while ((c = getopt(argc, argv, "If:n")) != -1)
switch(c) {
@ -516,8 +518,21 @@ main(int argc, char *argv[])
replacement = 0xfffd;
struct winsize w;
if (ioctl(1, TIOCGWINSZ, &w) == 0)
if (ioctl(1, TIOCGWINSZ, &w) == 0) {
cols = w.ws_col;
char *pg;
pg = getenv("MBLAZE_PAGER");
if (!pg)
pg = getenv("PAGER");
if (pg && *pg && strcmp(pg, "cat") != 0) {
pid1 = pipeto(pg);
if (pid1 < 0)
fprintf(stderr,
"mscan: spawning pager '%s': %s\n",
pg, strerror(errno));
}
}
if (getenv("COLUMNS"))
cols = atoi(getenv("COLUMNS"));
if (cols <= 40)
@ -550,5 +565,8 @@ main(int argc, char *argv[])
i = blaze822_loop(argc-optind, argv+optind, oneline);
fprintf(stderr, "%ld mails scanned\n", i);
if (pid1 > 0)
pipeclose(pid1);
return 0;
}

Loading…
Cancel
Save