### Copyright (C) 1996 Rasmus Ingemann Hansen
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


proc viewer {} {
    # Viewing / Viewer
    Desc "How to view received messages"
    ShortDesc "Viewer"

    Radio editorOptionsRadio2 \
	-text "Program to use for displaying messages" \
        -entryhelp {"Builtin (recommended)" "All you need for viewing messages." \
		    "Use another editor for viewing" "If you allways want to start ie. emacs to read your messages it might be a heavy and slow tool for short messages. Good alternative is \"less\"" } \
	-help "Location of preferable viewer. Please remember to write the complete path and name of viewer. If in doubt, type \"whereis\" with name of editor/viewer (ie. emacs, vi, ...)." \
        -packFrame:fill x
#####
    Line linee

    Radio viewerRadio1 \
	-text "Which builtin pager to use" \
        -entryhelp {"Builtin" "Simply `scrolls up' subsequent screenfulls once it has `paged' the first screenfull." \
		    "Builtin+ (recommended)" "Each screenfull of displayed message is `paged' from the top of your screen with a title line." } \
	-help "Which builtin pager to use" \
        -packFrame:fill x

### PREFERRED PAGER ###
    Header head2 \
	-text "Prefered pager for viewing" \
	-background lightgray

    File-Dir-Browser editorOptionsDir1 \
	-text "Location of prefered viewer" \
	-exist 1

    foreach widget { head2 editorOptionsDir1 } {
	Help $widget "Beware of following MIME topic:\nWhen you receive a mail message in the form of a MIME compliant message, Metamail is called automatically to display the message. Metamail asks you if you want to display each part of the message and uses the display programs available controlled by the \".mailcap\". So, eventhough your display pager in Elm above is set to Less, it might be displayed using the More pager! Therefore, you could specify in your \".mailcap\" to use Less on every mail:   \"text/plain; less -e %s\"."
    }

    CheckBox viewerCheckBox1 \
	-text "Pass (optional) commands to pager"
    Entry editorOptionsTextBox1 \
	-width 55
    foreach widget { viewerCheckBox1 editorOptionsTextBox1 } {
	Help $widget "Use it to pass commands ie. to `less' like \"less -cEw\" or \"less -C -e +Gg -M\" (if you experience problems when going back with builtin), or other settings to your chosen viewer."
    }

    Label label2 \
	-text "(don't specify options to the viewer in filebrowser entry. Use the above)"
###
    Line line3

    CheckBox viewerCheckBox3 \
	-text "Prompt for a command after the external pager exits" \
	-help "Selected to display a command prompt rather than the index screen when exiting from the external pager. If your external pager immediately exits when it reaches the end of the message, you should select it so that the last screen of the displayed message is not immediately replaced by the index screen. If your external pager doesn't exit until you command it to, you have a choice. If you usually want to see the index screen before issuing a command, setting this OFF eliminates the extra keystroke needed to return to the index screen. If you usually don't need to see the index screen before issuing the next command, selecting it allows you to enter your next command without waiting for the index screen to be redrawn. Default is selected."

    Line line5

    CheckBox viewerCheckBox2 \
	-text "Use builtin pager even usually use of the external pager entered above" \
	-help "This is used to determine if the builtin pager should be used on some messages even if you would usually use an external pager program. Any messages shorter than \"n\" lines should use builtin pager"

    Int viewerInt1 \
	-text "Messages shorter than" \
	-textafter "lines should be viewed by builtin pager" \
	-width 3 \
	-help "Parameter to zero then message always being sent through external pager"

  ################################ Change #################################
    Change {
	if {$editorOptionsRadio2(index)==0} {
		Enable viewerRadio1
		Disable editorOptionsDir1
		Disable viewerCheckBox2
		Disable viewerInt1
		Disable viewerCheckBox1
		Disable editorOptionsTextBox1
		Disable viewerCheckBox3
		} {
		Disable viewerRadio1
		Enable editorOptionsDir1
		Enable viewerCheckBox2
		Enable viewerInt1
		Enable viewerCheckBox1
		Enable viewerCheckBox3
		if {$viewerCheckBox2==0} {
			Disable viewerInt1
		} else {
			Enable viewerInt1
		}
		if {$viewerCheckBox1==0} {
			Disable editorOptionsTextBox1
		} else {
			Enable editorOptionsTextBox1
		}
	}
    }

  ############################## Init / Save ##############################

    Init {
    }

    Save {
	if {$editorOptionsRadio2(index)==0} {
		print "\n# program to use for displaying messages ('builtin' is recommended)"
		if {$viewerRadio1(index)==0} {
			print "pager = builtin"
		} else {
			print "pager = builtin+"
		}
	} else {
		print "\n# program to use for displaying messages ('builtin' is recommended)"
		if {$viewerCheckBox1==0} {
			print "pager = $editorOptionsDir1"
		} else {
			print "pager = $editorOptionsDir1 $editorOptionsTextBox1"
		}
	}

	print "\n# prompt for a command after external pager exits"
	if {$viewerCheckBox3==0} {
		print "promptafter = OFF"
	} else {
		print "###promptafter = ON"
	}

	print "\n# any messages shorter than \"n\" lines should use builtin pager"
	if {$viewerCheckBox2==0} {
		print "builtinlines = 0"
	} else {
		print "builtinlines = $viewerInt1"
	}
    }
}



