diff options
author | ru <ru@FreeBSD.org> | 2011-06-03 05:16:33 +0000 |
---|---|---|
committer | ru <ru@FreeBSD.org> | 2011-06-03 05:16:33 +0000 |
commit | fb0246d603cb7d3a1c508125d386c36546e1dae1 (patch) | |
tree | cc27532f4ee40ff43900fbb2841d57efe3e51649 /usr.bin/man | |
parent | 9e7829f5b0959ac481e7f884997ef86152ad161f (diff) | |
download | FreeBSD-src-fb0246d603cb7d3a1c508125d386c36546e1dae1.zip FreeBSD-src-fb0246d603cb7d3a1c508125d386c36546e1dae1.tar.gz |
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.
Diffstat (limited to 'usr.bin/man')
-rw-r--r-- | usr.bin/man/man.1 | 8 | ||||
-rwxr-xr-x | usr.bin/man/man.sh | 40 |
2 files changed, 46 insertions, 2 deletions
diff --git a/usr.bin/man/man.1 b/usr.bin/man/man.1 index 58f43e5..133d536 100644 --- a/usr.bin/man/man.1 +++ b/usr.bin/man/man.1 @@ -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, diff --git a/usr.bin/man/man.sh b/usr.bin/man/man.sh index 762970d..972f872 100755 --- a/usr.bin/man/man.sh +++ b/usr.bin/man/man.sh @@ -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 |