### 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.

######################################################################
###                         Prompt General
######################################################################
proc prompt_general {} {
  # prompt / general
  
  Desc "Here you configure things which are general for all commands"\
      "which use prompts. (prompt, promtp2, prompt3, history and sched)"

  ShortDesc "Configuration related to prompts"


  ############################### Widgets ##############################
  Radio ellipsis \
      -text "How to show skiped directories" \
      -count 1 -entries {
        "with three dots" "with a number indicating the number skiped"} 

  Space 10
  
  Entry superchar \
      -text "Super user Char\t" \
      -default "\#" \
      -width 2
  
  Entry userchar \
      -text "ordinary user Char\t" \
      -default ">" \
      -width 2

  ################################ Help ################################
  Help ellipsis\
      "If the prompt shows which directory you are located in, it may"\
      "be useful to skip some of the directories if you are deep down"\
      "in the directory tree. For each prompt you can specify how deep"\
      "you have to be before directories are skipped.\n\n This option"\
      "specifies how skipped directories are shown. See help for each"\
      "element for an example"
  
  EntryHelp ellipsis "with three dots" \
      "If this option is selected, skipped directories are shown with"\
      "three dots.\n\n Example:\n ~/a/b/c/d will be shown as ~...c/d\n"\
      "/a/b/c/d will be shown as .../c/d"

  EntryHelp ellipsis "with a number indicating the number skiped" "If"\
      "this option is selected skipped directories are show inside"\
      "<>\n\n Example:\n ~/a/b/c/d are shown as ~/<2>c/d\n /a/b/c/d are"\
      "shown as /<2>c/d"

  Help superchar "In a prompt you can select an element called"\
      "\"superuser character\". This character have two different"\
      "values, depending on whether you are the super user (root) or"\
      "not.\n In this Entry you can specify which character to be used,"\
      "when the user is the super user."
  
  Help userchar "In a prompt you can select an element called"\
      "\"superuser character\". This character have two different"\
      "values, depending on whether you are the super user (root) or"\
      "not.\n In this Entry you can specify which character to be used,"\
      "when the user is *NOT* the super user."

  ############################### Change ###############################
  Change {
    switch $changeElm {
      superchar {
        if {[string length $superchar] > 1} {
          set superchar [string range $superchar 0 0]
        }
      }
      userchar {
        if {[string length $userchar] > 1} {
          set userchar [string range $userchar 0 0]
        }
      }
    }
  }

  ################################ Save ################################
  Save {
    ########## ellipsis ##########
    if {$ellipsis(index) || $generateDefault} {
      print "[pick $ellipsis(index) set unset] ellipsis"
    }
    ########## promptchars ##########
    if {$superchar != "\#" || $userchar != ">" || $generateDefault} {
      if {$superchar != "\#" || $userchar != ">"} {
        print "set promptchars=\"$userchar$superchar\""
      } else {
        print "unset promptchars"
      }
    }
  }
}

######################################################################
###                         Prompt 1
######################################################################
proc prompt {} {
  # prompt / prompt

  Desc "This is the string which is printed before reading each command"\
      "from  the terminal. The options above will be expanded in the string."\
      "Eg. \"current working dir\" will expand to the  current working"\
      "directory at the time the prompt is shown."
  
  promptWidget {} {} {{General prompt} {This is the standard prompt}}
  Save {
    ########## prompt ##########
    print "set prompt=\"$prompt\""
  }
}

######################################################################
###                        Prompt 2
######################################################################
proc prompt2 {} {
  # prompt / prompt 2

  Desc "This is the string with which will be prompted in \"while\" and"\
      "\"foreach loops\" and after lines ending in `\\'.  The options"\
      "above will be expanded in the string.  Eg. \"current working"\
      "dir\" will expand to the current working directory at the time"\
      "the prompt is shown."
  
  promptWidget {%R%? } {"Status of the parser" "Parser" {This is expanded to "foreach" in a foreach loop, "while" in a while loop and nothing after lines ending in '\'}} {
      {Prompt 2} {This prompt is used in foreach and while loops and after 
	lines ending in `\\'}}
  Save {
    ########## prompt2 ##########
    if {$prompt != {%R? } || $generateDefault} {
      print "set prompt2=\"$prompt\""
    }
  }
}

######################################################################
###                        Prompt 3
######################################################################
proc promtpt3 {} {
  # prompt / prompt 3

  Desc "This is the string which is printed when confirming automatic"\
      "spelling correction. The options above will be expanded in the"\
      "string. Eg.  \"current working dir\" will expand to the current"\
      "working directory at the time the prompt is shown."
  
  promptWidget {CORRECT>%R% (y|n|e|a)? } {"The corrected String" "Corrected" {This is the string, the shell suggest, when it is trying to teach you to spell}} {{Prompt 3} {This prompt is used in spell checking}}
  Save {
    ########## prompt3 ##########
    if {$prompt != {CORRECT>%R (y|n|e|a)? } || $generateDefault} {
      print "set prompt3=\"$prompt\""
    }
  }
}
