Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/aux/mpage/Contrib/mp

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/sh -
#
# REMARKS:
#
# Useful stuff for Ghostview in .Xdefaults:
#
#     Ghostview*printCommand: /users/franky/bin/psprint
#     Ghostview*swapLandscape: true
#     Ghostview*horizontalMargin: 10
#     Ghostview*verticalMargin: 10
#
# Useful environment variables:
#
#     LPDEST=hp4
#

TMPFILE=/tmp/mp$$.ps
MPAG=/usr/local/bin/mpage
PSPRINT=/usr/local/bin/psprint
GV=/usr/local/bin/ghostview
RM=/bin/rm


Help() {
    cat << "EOF"
mp -- view or print using mpage

      To print a file:
	mp -p [-{1,2,4,8}] [mpage-options] file
     
      To view a file:
	mp [-v[{0,1,2,3}]] [-{1,2,4,8}] [mpage-options] file

      Options:
	-p	print a file
	-v	view file at magstep -1 (default)
	-v0	view file at magstep  0
	-v1	view file at magstep -1
	-v2	view file at magstep -2
	-v3	view file at magstep -3

	-1	view/print one page per screen
	-2	view/print two pages per screen
	-4	view/print four pages per screen (default)
	-8	view/print eight pages per screen

	mpage-options are passed to mpage

EOF
}

if [ "$1" = "" ]; then
    Help
    exit 1
fi

PRINTING=0
MAGSTEP=1
case $1 in
    -h)		Help	  ; exit 1 ;;
    -p) 	PRINTING=1 ; shift ;;
    -v) 	MAGSTEP=1 ; shift ;;
    -v0)	MAGSTEP=0 ; shift ;;
    -v1)	MAGSTEP=1 ; shift ;;
    -v2) 	MAGSTEP=2 ; shift ;;
    -v3)	MAGSTEP=3 ; shift ;;
esac

MARGIN=l
case $1 in
    -2) MARGIN=r ;;
    -8) MARGIN=r ;;
esac

# ASSUMED OPTIONS IN EFFECT: -H -f -A -a
#
${MPAG} -m20lbrt -m50"${MARGIN}" $* > $TMPFILE
#
if [ "${PRINTING}" = "1" ]; then
    ${PPSPRINT} $TMPFILE
else
    ${GV} -magstep -"${MAGSTEP}" $TMPFILE
fi

${RM} -f $TMPFILE

exit 0

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.