#!/bin/csh -f
# A script to call a postscript previewer.  Try gv first (standard on early
# Redhat 7?), then xpsview for SGI, then gs, which is not as good as gv

# But first test for windows and call gsview32 there
#
which cygpath >& /dev/null
if (! $status) then
    which gsview32 >& /dev/null
    if ($status) goto failed
    gsview32 $*
    exit 0
endif

# Then test for -p flag and print
#
if ("$argv[1]" == '-p') then
    shift
    lp $*
    exit 0
endif

# 12/2/05: Needed two -- on the noanti.  Did it really work with 1 before?
which gv >& /dev/null
if (! $status) then
    gv --noanti $*
    exit 0
endif

which xpsview >& /dev/null
if (! $status) then
    xpsview $*
    exit 0
endif

which gs >& /dev/null
if (! $status) then
    echo " "
    echo "TYPE CTRL C TO EXIT THE GS PREVIEWER"
    echo
    gs $*
    exit 0
endif

failed:
echo "imodpsview cannot find a PostScript previewer on your system"
echo "If you have one, modify $IMOD_DIR/bin/imodpsview to call it"
