### Copyright (C) 1995-1997 Jesper K. Pedersen
### 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 dirs {} {
  # dirs command

  Desc "Here you configure the use of the directory stack. See the"\
      "'Directory stack substitution' section in the tcsh manual for"\
      "more information"
  
  ShortDesc "Configuration of directory stack"

  ############################### Widgets ##############################
  File-Dir-Browser dirsfile \
      -text "location for directory stack" \
      -default "~/.cshdirs" \
      -showHidden
  
  CheckBox dunique \
      -text "remove duplicates in dir stack"

  CheckBox pushdtohome \
      -text "Let pushd without argument push to home directory"
  
  CheckBox pushdsilent \
      -text "Show directory stack on pushd and popd commands"

  CheckBox savedirs \
      -text "save directory stack before exit"

  Radio dextract \
      -text "What to do with \"dirs +n\"" \
      -entries { "rotate list" "move element to top"} 

  ################################ Help ################################
  foreach elm {dirsfile com_dirsfile} {
    Help $elm "Directory stack can be saved / loaded with"\
        "dirs -S and dirs -L respectively. Here you can say which"\
        "file to save this information in."
  }

  Help dunique \
      "If this option is selected, then multiple instances of an argument"\
      "to pushd are removed before it is pushed onto the stack."\
      "This way the directory stack will not have two elements which are alike"

  Help pushdtohome \
      "If this option is selected pushd without any argument"\
      "pushes the directory stack to home. This is the behavior of \"cd\""

  Help pushdsilent \
      "If this option is selected the directory stack will be printed"\
      "each time either pushd or popd is invoked"

  Help savedirs \
      "If this option is selected, the directory stack is save from"\
      "session to session."

  Help dextract \
      "This configures the use of dirs +n, where n is a number."\
      "See the help for the two elements for description on each one."

  EntryHelp dextract "rotate list"\
      "If you select this method, then the list will be rotated so that"\
      "the specific element will be at the top. \n\nExample:\ndirs ="\
      "\"/usr/local/ /home/blackie /var\"\npushd +1 will give the"\
      "following list:\n/home/blackie /var /usr/local/"

  EntryHelp dextract "move element to top" \
      "If you select this method, then the element will be moved to the"\
      "top of the list, and all the other elements will not move, apart"\
      "from the movement due to when an element is inserted at the"\
      "top. \n\nExample:\ndirs = \"/usr/local/ /home/blackie /var\""\
      "\npushd +1 will give the following list: \n/home/blackie"\
      "/usr/local/ /home/blackie /var"

  ################################ Save ################################
  Save {
    ########## dirsfile ##########
    if {$dirsfile != "~/.cshdirs" || $generateDefault} {
      if {$dirsfile == "~/.cshdirs"} {
        print "unset dirsfile"
      } else {
        print "set dirsfile = $dirsfile"
      }
    }

    ########## dunique ##########
    if {$dunique || $generateDefault} {
      print "[pick $dunique set unset] dunique"
    }
    ########## pushdtohome ##########
    if {$pushdtohome || $generateDefault} {
      print "[pick $pushdtohome set unset] pushdtohome"
    }
    ########## pushdsilent ##########
    if {$pushdsilent || $generateDefault} {
      print "[pick $pushdsilent unset set] pushdsilent"
    }
    ########## savedirs ##########
    if {$savedirs || $generateDefault} {
      print "[pick $savedirs set unset] savedirs"
    }
    ########## dextract ##########
    if {$dextract(index) == 1 || $generateDefault} {
      print "[pick $dextract(index) set unset] dextract"
    }
  }
}
