### Copyright (C) 1996 Per Zacho
### 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 job {} {
    # User<->Bash interface / Job control

    Desc "This configuration page will help you to setup options regarding"\
    "job control."

    ShortDesc "Job control"

    ### Job control ###

    Header head1 -text "Job control"\
	    -background gray\
	    -help "Options concerning job control."

    CheckBox monitor -text "Allow job control"\
	    -default 1\
	    -help "This option has influence on two things according to the manual. For the first"\
	    "it controls how Bash will handle background processes, and secondly, whether to"\
	    "print information about exit status upon termination of background processes or not."\
	    "\nExample: to illustrate how option \"job control\" influence background processes."\
	    "Try to start a background process (like emacs) in X-windows and terminate the shell"\
	    "with this option enabled and then disabled to see the difference."

    Line line1

    Menu autoResume -text "Fast resume of suspended jobs (auto-resume)"\
	    -entryhelp {"disabled" "Don't use fast resume of suspended jobs."\
	    "substring" "Only a substring of word has to match name of suspended job."\
	    "prefix" "Word has to be prefix of name of suspended job."\
	    "exact" "Word has to match name of suspended job."}\
	    -help "Auto-resume is a way to start suspended jobs without having to use the"\
	    "dedicated \%-commands. When this option is enabled, single words without"\
	    "redirection are treated as candidates for auto-resumption. If more than one job"\
	    "match the word, the first is selected for resumption."\
	    -width 10

    Line line2

    Radio terminate -text "When is Bash to notify of terminating background jobs?"\
	    -defaultIndex 0\
	    -entryhelp {"before primary prompt" "Wait until next prompt will print."\
	    "notify immediately" "Print information about exit status when available."}\
	    -help "When a background process terminate, it will report with status on how"\
	    "program terminated. This information can be reported either before next command"\
	    "prompt or immediately--even if another program is using the screen/window."\
	    -packFrame:fill x

    Change {
	if {$monitor} {Enable terminate} {Disable terminate}
    }

    Save {
	### Job control ###
	if {$monitor != 1 || $generateDefault} {
	    print "set [pick $monitor - +]o monitor"
	}

	if {$autoResume(index) || $generateDefault} {
	    if {$autoResume(index)} {
		print "export auto_resume=$autoResume(name)"
	    } {
		print "unset auto_resume"
	    }
	}

	if {($terminate(index) && $monitor) || $generateDefault} {
	    print "set [pick $terminate(index) - +]b"
	}
    }
}
