### 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 editor {} {
    # Editing / Editor
    Desc "Editor for writing (new) messages"
    ShortDesc "Editor (for new messages)"

    Header head1 \
	-text "Editor you want to write (new) messages with" \
	-background gray \
	-help "Editor to use when typing new mail ie. builtin or emacs, jove, pico, vi, vim..."

    Radio editorRadio1 \
	-text "" \
        -defaultIndex 0 \
        -entryhelp {"Use editor of your own choice" "If you allways want to start ie. emacs to write your messages (even for very short messages)." \
		    "Use builtin = simulate Berkeley Mail" "A much easyer and quicker editor than ie. emacs with much fewer commands. Brilliant for sending short messages. Offcause, directly from this builtin editor you can start 'easyeditor' (ie. emacs) or 'visualeditor' (ie. vi) whenever you choose to."} \
	-help "" \
        -packFrame:fill x

    File-Dir-Browser editorDir1 \
	-text "Location of prefered editor" \
	-exist 1
    foreach widget { editorDir1 } {
	Help $widget "If in doubt of location please: 1) type in only the name (ie. \"emacs\") if you have a path for that editor, that is simply typing in the (ie. \"emacs\") activates that editor. Or 2) type \"which/whereis emacs\" for correct location. You can add any commandline options (like 'emacs -nw')."
    }

    File-Dir-Browser editorDir5 \
	-text "Location of 'easyeditor' (~e command)" \
	-default "/usr/bin/emacs" \
	-exist 1
    foreach widget { editorDir5 } {
	Help $widget "The editor to be used by the \"~e\" escape within the builtin editor. If in doubt of location please: 1) type in only the name (ie. \"emacs\") if you have a path for that editor, that is simply typing in the (ie. \"emacs\") activates that editor. Or 2) type \"which/whereis emacs\" for correct location. You can add any commandline options (like 'emacs -nw')." \
    }

    File-Dir-Browser editorDir6 \
	-text "Location of 'visualeditor' (~v command)" \
	-default "/usr/bin/emacs" \
	-exist 1
    foreach widget { editorDir6 } {
	Help $widget "The editor to be used by the \"~v\" escape within the builtin editor. If in doubt of location please: 1) type in only the name (ie. \"vi\") if you have a path for that editor, that is simply typing in the (ie. \"vi\") activates that editor. Or 2) type \"which/whereis vi\" for correct location. You can add any commandline options (like 'emacs -nw')." \
    }

    File-Dir-Browser editorDir7 \
	-text "Editor when mailing to a message including text" \
	-default "/usr/bin/emacs" \
	-exist 1
    foreach widget { editorDir7 } {
	Help $widget "The editor to use when mailing to a message that already includes text, as the builtin editor cannot handle that situation. Messages that already include text are forwarded messages and replies where the original message is included in the reply. This could be emacs or vi. If in doubt of location please type simple the name (ie. \"emacs\") or \"which emacs/vi\" for correct location."
    }

    Entry editorEntry6 \
	-text "Character to use in the builtin editor for entering commands" \
	-help "The character used with the builtin editor to escape from text entry to input a command. When a line begins with this character, the builtin editor interprets it as a command rather than as text to add. The default is `~' (tilde)." \
	-default "~" \
	-width 2


  ################################ Change #################################
    Change {
	if {$editorRadio1(index)==1} {
		Disable editorDir1
	        Enable editorDir5
	        Enable editorDir6
	        Enable editorDir7
                Enable editorEntry6
	} else {
		Enable editorDir1
	        Disable editorDir5
	        Disable editorDir6
	        Disable editorDir7
                Disable editorEntry6
	}

    }

  ################################# Init ##################################
    Init {
    }

  ################################# Save ##################################

    Save {
	print "\n# what editor to use (\"none\" means simulate Berkeley Mail)"
	if {$editorRadio1(index)==0} {
		print "editor = $editorDir1"
	} else {
		print "editor = none"
	}
	print "\n# name of editor for ~e command (when editor=\"builtin)\"\neasyeditor = $editorDir5"
	print "\n# name of editor for ~v command (when editor=\"builtin)\"\nvisualeditor = $editorDir6"
	print "\n# name of editor to use for replies that have text\nalteditor = $editorDir7"

	print "\n# the character to use in the builtin editor for entering commands"
	if {$editorEntry6=="~"} {
		print "###escape = ~"
	} else {
		print "escape = $editorEntry6"
	}

    }
}



