Added support for the MANWIDTH environment variable:
If set to a numeric value, used as the width manpages should be displayed. Otherwise, if set to a special value ``tty'', and output is to a terminal, the pages may be displayed over the whole width of the screen.
This commit is contained in:
parent
cd507188bc
commit
a00944499f
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222635
@ -25,7 +25,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd September 1, 2010
|
||||
.Dd June 2, 2011
|
||||
.Dt MAN 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -283,6 +283,12 @@ Restricts manual sections searched to the specified colon delimited list.
|
||||
Corresponds to the
|
||||
.Fl S
|
||||
option.
|
||||
.It Ev MANWIDTH
|
||||
If set to a numeric value, used as the width manpages should be displayed.
|
||||
Otherwise, if set to a special value
|
||||
.Dq Li tty ,
|
||||
and output is to a terminal,
|
||||
the pages may be displayed over the whole width of the screen.
|
||||
.It Ev PAGER
|
||||
Program used to display files.
|
||||
If unset,
|
||||
|
@ -112,7 +112,11 @@ check_man() {
|
||||
setup_cattool $manpage
|
||||
decho " Found manpage $manpage"
|
||||
|
||||
if exists "$2" && is_newer $found $manpage; then
|
||||
if [ -n "${use_width}" ]; then
|
||||
# non-standard width
|
||||
unset use_cat
|
||||
decho " Skipping catpage: non-standard page width"
|
||||
elif exists "$2" && is_newer $found $manpage; then
|
||||
# cat page found and is newer, use that
|
||||
use_cat=yes
|
||||
catpage=$found
|
||||
@ -352,6 +356,10 @@ man_display_page() {
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -n "${use_width}" ]; then
|
||||
NROFF="$NROFF -rLL=${use_width}n -rLT=${use_width}n"
|
||||
fi
|
||||
|
||||
if [ -n "$MANROFFSEQ" ]; then
|
||||
set -- -$MANROFFSEQ
|
||||
while getopts 'egprtv' preproc_arg; do
|
||||
@ -562,6 +570,35 @@ man_setup() {
|
||||
|
||||
build_manpath
|
||||
man_setup_locale
|
||||
man_setup_width
|
||||
}
|
||||
|
||||
# Usage: man_setup_width
|
||||
# Set up page width.
|
||||
man_setup_width() {
|
||||
local sizes
|
||||
|
||||
unset use_width
|
||||
case "$MANWIDTH" in
|
||||
[0-9]*)
|
||||
if [ "$MANWIDTH" -gt 0 2>/dev/null ]; then
|
||||
use_width=$MANWIDTH
|
||||
fi
|
||||
;;
|
||||
[Tt][Tt][Yy])
|
||||
if { sizes=$($STTY size 0>&3 2>/dev/null); } 3>&1; then
|
||||
set -- $sizes
|
||||
if [ $2 -gt 80 ]; then
|
||||
use_width=$(($2-2))
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
if [ -n "$use_width" ]; then
|
||||
decho "Using non-standard page width: ${use_width}"
|
||||
else
|
||||
decho 'Using standard page width'
|
||||
fi
|
||||
}
|
||||
|
||||
# Usage: man_setup_locale
|
||||
@ -900,6 +937,7 @@ VGRIND=vgrind
|
||||
|
||||
COL=/usr/bin/col
|
||||
LOCALE=/usr/bin/locale
|
||||
STTY=/bin/stty
|
||||
SYSCTL=/sbin/sysctl
|
||||
|
||||
debug=0
|
||||
|
Loading…
Reference in New Issue
Block a user