#!../treesh/treesh -f
#
# Dirtree.tcl - directory tree browser
#
# -----------------------------------------------------------------------------
# Copyright 1993 Allan Brighton.
# 
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted,
# provided that the above copyright notice appear in all copies.  Allan
# Brighton make no representations about the suitability of this software
# for any purpose.  It is provided "as is" without express or implied
# warranty.
# -----------------------------------------------------------------------------


# Create the main window and initialize the tree to 
# the given dir.
#
# If width and height are specified, they are used for the
# size of the canvas window.

proc dirtreeMakeWindow {dir} {
    global dirtree 
    set frame .frame
    set canvas $frame.canvas
    set tree $canvas.tree
    set menubar .menubar
    
    wm minsize . 10 10
    wm iconbitmap . @bitmaps/dirtree.xbm
    
    frame $frame
    dirtreeMakeMenuBar $canvas $tree $menubar $dir
    pack $frame -side top -expand yes -fill both 
    canvas_create $frame $canvas
    
    # declare the tree
    tree $tree  
    
    # add root dir
    dirtreeAddDir $canvas $tree "" $dir [utilDirTail $dir]
    dirtreeListDirs $canvas $tree $dir
    $tree draw
    tkwait visibility $canvas
    tree_center $tree
    dirtreeBindings $canvas $tree
}


# make the tree window's menu bar
#
# Args:
#
# canvas -  the canvas containing the tree
# tree   -  the tree widget
# menubar - the name to use for the menubar frame
# dir     - the initial directory

proc dirtreeMakeMenuBar {canvas tree menubar dir} {
    global dirtree
    frame $menubar -relief raised -bd 2
    pack $menubar -side top -fill x -ipady 1m
   
    # menu items
    
    # file menu
    menubutton $menubar.file -text "File" -menu $menubar.file.m
    menu $menubar.file.m
    pack $menubar.file -side left
    $menubar.file.m add command -label "New Window" -command "exec dirtree $dirtree(argv) &"
    $menubar.file.m add separator
    $menubar.file.m add command -label "Exit" -command {exit 0}
    
    # view menu
    menubutton $menubar.view -text "View" -menu $menubar.view.m
    menu $menubar.view.m -post "dirtreeUpdateViewMenu $canvas $tree $menubar.view.m"
    pack $menubar.view -side left -padx 1m -ipadx 1m
    $menubar.view.m add command -label "Open File List" \
	-command "dirtreeShowFiles $canvas $tree"
    $menubar.view.m add command -label "Add Subdirs" \
	-command "dirtreeToggleChildren $canvas $tree"
    $menubar.view.m add command -label "Add Parent" \
	-command "dirtreeToggleParent $canvas $tree"
    $menubar.view.m add command -label "Hide Dir" \
	-command "dirtreeHideNode $canvas $tree"
    $menubar.view.m add separator
    $menubar.view.m add command -label "Vertical Layout" \
	-command "dirtreeToggleLayout $canvas $tree"
    
    # directory text entry item for setting a new root of the tree
    frame $menubar.dirframe
    label $menubar.dirlabel -text "Dir:"
    entry $menubar.direntry -width 25 -relief sunken -textvariable dirtree(direntry)
    set dirtree(direntry) $dir 
    wm iconname . [utilDirTail $dir]
    pack $menubar.dirframe -side right -padx 1m -ipadx 1m
    pack $menubar.dirlabel $menubar.direntry -side left -in $menubar.dirframe

    bind $menubar.direntry <Return> "dirtreeSetNewRoot $canvas $tree \$dirtree(direntry)"
}


# This procedure is called each time the View menu is displayed
# to update the menu to reflect the current selection
# (This must be kept up to date with the above procedure that creates the menu)

proc dirtreeUpdateViewMenu {canvas tree menu} {
    
    if {[set path [dirtreeGetPath $canvas]] == ""} {
	$menu entryconfig 0 -state disabled
	$menu entryconfig 1 -state disabled
	$menu entryconfig 2 -state disabled
	$menu entryconfig 3 -state disabled
    } else {
	if [llength [$canvas find withtag $path:list]] {
	    $menu entryconfig 0 -label "Close File List" -state normal
	} else {
	    $menu entryconfig 0 -label "Open File List"  -state normal
	}
	
	if [$tree isleaf $path] {
	    $menu entryconfig 1 -label "Add Subdirs"  -state normal
	} else {
	    $menu entryconfig 1 -label "Remove Subdirs" -state normal
	}
	
	if [$tree isroot $path] {
	    $menu entryconfig 2 -label "Add Parent Dir" -state normal
	    $menu entryconfig 3 -state disabled
	} else {
	    $menu entryconfig 2 -label "Begin Tree Here" -state normal
	    $menu entryconfig 3 -state normal
	}
    }
    if {[utilGetConfigValue $tree -layout] == "horizontal"} {
	$menu entryconfig 5 -label "Vertical Layout"
    } else {
	$menu entryconfig 5 -label "Horizontal Layout"
    }
}


# set the bindings for the tree canvas

proc dirtreeBindings {canvas tree} {
    
    #drag&drop source $canvas -button 3 -tokencmd "dirtreePackageDir $canvas" -sendcmd dirtreeSendDir

    $canvas bind text <1> "focus %W; dirtreeSelectNode $canvas $tree"
    $canvas bind text <2> "dirtreeShowFiles $canvas $tree"
    $canvas bind text <Double-Button-1> "dirtreeToggleChildren $canvas $tree"
    $canvas bind bitmap <1> "dirtreeSelectBitmap $canvas $tree"
    $canvas bind bitmap <Double-Button-1> "dirtreeToggleParent $canvas $tree"
   
    bind $canvas <ButtonPress-2> "$canvas scan mark %x %y"
    bind $canvas <B2-Motion> "$canvas scan dragto %x %y"
    bind $canvas <Left> "dirtreeSelectNext $canvas $tree %K"
    bind $canvas <Right> "dirtreeSelectNext $canvas $tree %K"
    bind $canvas <Down> "dirtreeSelectNext $canvas $tree %K"
    bind $canvas <Up> "dirtreeSelectNext $canvas $tree %K"
    bind $canvas <Return> "dirtreeToggleChildren $canvas $tree"
    
    # Cut key on Sun keyboard removes node
    bind $canvas <L10> "dirtreeHideNode $canvas $tree"
    bind $canvas <Control-d> "dirtreeHideNode $canvas $tree"
}


# set the bindings for a file list in the tree canvas

proc dirtreeFileListBindings {canvas tree frame list scroll dir} {
    global dirtree
    bind $frame <ButtonPress-1> "dirtreeResizeList $canvas $tree $frame $list %x %y $dir first"
    bind $frame <Button1-Motion> "dirtreeResizeList $canvas $tree $frame $list %x %y $dir"
    bind $frame <ButtonRelease-1> "dirtreeResizeList $canvas $tree $frame $list %x %y $dir last"
    
    #drag&drop source $list -button 3 -tokencmd "dirtreePackageFile $dir %W" -sendcmd dirtreeSendFile
    bind $list <1>  "set dirtree(list) %W; set dirtree(dir) $dir; [bind Listbox <1>]"
    bind $list <Double-Button-1> dirtreeOpenFile
    
    # set/clear the resize cursor
    bind $list <Any-Enter> "$frame config -cursor {}"
    bind $list <Any-Leave> "$frame config -cursor bottom_right_corner"
    bind $scroll <Any-Enter> "$frame config -cursor {}"
    bind $scroll <Any-Leave> "$frame config -cursor bottom_right_corner"
}


# Erase the tree and make dir the new root 

proc dirtreeSetNewRoot {canvas tree dir} {
    # get the normalized pathname
    set path [exec /bin/csh -cf "if ( -d ${dir}/ ) cd $dir; pwd"]
    
    if {"$path" == "" || ![file isdirectory $path]} {return}
    
    $tree prune ""
    dirtreeAddDir $canvas $tree "" $path [utilDirTail $path]
    dirtreeListDirs $canvas $tree $path
    $tree draw
    
    # update the dir entry
    global dirtree
    set dirtree(direntry) $path
    set dirtree(list) ""
    wm iconname . [utilDirTail $dir]
}


# drag&drop send command for files

proc dirtreeSendFile {interp ddwin path} {
   teCatchErr {
       send $interp "te_receiveDragFile $path"
       send $interp "drag&drop target $ddwin handle file"
   }
}


# drag&drop send command for directories

proc dirtreeSendDir {interp ddwin path} {
   teCatchErr {
       send $interp "receiveDragDir $path"
       send $interp "drag&drop target $ddwin handle dir"
   }
}


# drag&drop token command for files

proc dirtreePackageFile {dir list win} {
    teCatchErr {
	set path [dirtreeGetFilename]
	if {"$path" == ""} {error ""}
	if {[winfo children $win] == ""} {
	    global dirtree
	    set bg $dirtree(bitmapSelectColor)
	    label $win.bitmap -bitmap "@bitmaps/file.xbm" -bg $bg -relief raised
	    label $win.label -text "" -bg $bg -relief sunken
	    pack $win.bitmap $win.label -side left
	}
	$win.label config -text [file tail $path]
    } 
    return $path
}


# drag&drop token command for directories

proc dirtreePackageDir {canvas win} {
    teCatchErr {
	set path [dirtreeGetPath $canvas]
	if {"$path" == ""} {error ""}
	if {[winfo children $win] == ""} {
	    global dirtree
	    set bg $dirtree(bitmapSelectColor)
	    label $win.bitmap -bitmap "@bitmaps/dir.xbm" -bg $bg -relief raised
	    label $win.label -text "" -bg $bg -relief sunken
	    pack $win.bitmap $win.label -side left
	}
	$win.label config -text [file tail $path]
    } 
    return $path
}



# select the current node's label

proc dirtreeSelectNode {canvas tree} {
    $canvas select from current 0
    $canvas select to current [string length [lindex [$canvas itemconf current -text] 4]]
    dirtreeDeSelectBitmap $canvas
}




# select the current node's parent, child or sibling
# depending on the value of direction (Left, Right, Up or Down)

proc dirtreeSelectNext {canvas tree direction} {
    set id [$canvas select item]
    set path [lindex [$canvas gettags $id] 0]
    
    # for vertical trees its different...
    if {[utilGetConfigValue $tree -layout] == "vertical"} {
	case $direction in {
	    Left	{set direction Up}
	    Right	{set direction Down}
	    Up	{set direction Left}
	    Down	{set direction Right}
	}
    }
    
    case $direction in {
        Left	{
        	    set node [$tree parent $path]
         	    if {"$node" == ""} {
         	        dirtreeToggleParent $canvas $tree
         	        set node [$tree parent $path]
        	    }
       	}
        Right	{
        	    set node [$tree child $path]
        	    if {"$node" == ""} {
			dirtreeListDirs $canvas $tree $path
        	        set node [$tree child $path]
			$tree draw
        	    }
                }
        Down	{
        	    set node [$tree sibling $path]
        	    if {"$node" == ""} {
        	        set node [$tree child [$tree parent $path]]
        	    }
        	}
        Up	{
        	    set next [$tree child [$tree parent $path]]
		    while {"$next" != ""} {
		        set node $next
		        set next [$tree sibling $next]
		        if {"$next" == "$path"} {
		            break;
		        }
		    }
                }
        default {return}
    }
    if {"$node" != ""} {
        set next [lindex [$canvas find withtag $node] 1]
        $canvas select from $next 0
        $canvas select to $next [string length [lindex [$canvas itemconf $next -text] 4]]
    }
}


# de-select all node labels

proc dirtreeDeselectNode {canvas tree} {
    $canvas select clear
}


# return the pathname (dir) for the item currently selected (bitmap or text)

proc dirtreeGetPath {canvas} {
    set id [$canvas select item]
    if {"$id" == ""} {
        return [lindex [$canvas gettags selected] 0]
    }
    return [lindex [$canvas gettags $id] 0]
}

  
# Return the current filename (from the list, with dirname) 
# if one is selected

proc dirtreeGetFilename {} {
    global dirtree
    set dir $dirtree(dir)
    set list $dirtree(list)
    if {"$dir" == "" || "$list" == ""} {return ""}
    
    set sel [$list curselection]
    if {![llength $sel]} {return ""}
    return $dir/[$list get [lindex $sel 0]]
}
    
  


# If the selection is a directory, toggle
# its state between closed and open

proc dirtreeToggleChildren {canvas tree} {
    set path [dirtreeGetPath $canvas]
     if [$tree isleaf $path] {
	dirtreeListDirs $canvas $tree $path
     } else {
	$tree prune $path
    }
    $tree draw
}



# highlight the node's bitmap

proc dirtreeSelectBitmap {canvas tree} {
    global dirtree
    focus none
    set path [lindex [$canvas gettags current] 0]
    dirtreeDeselectNode $canvas tree
    dirtreeDeSelectBitmap $canvas
    $canvas itemconfig current -background $dirtree(bitmapSelectColor) -tags "[$canvas gettags current] selected" 
}



# stop highlighting the node's bitmap

proc dirtreeDeSelectBitmap {canvas} {
    $canvas itemconfig selected -background [utilGetConfigValue $canvas -background]
    $canvas dtag selected
}



# If the selection is a directory, make it the new root of the tree
#
# If the node already is the root, the node's parent is added
# to the tree

proc dirtreeToggleParent {canvas tree} {
    global dirtree
    set path [dirtreeGetPath $canvas]
    dirtreeDeSelectBitmap $canvas
    if [$tree isroot $path] {
       set dir [file dirname $path]
       if {$dir != $path} {
	    dirtreeAddDir $canvas $tree "" $dir [utilDirTail $dir]
	    set dirtree(direntry) $dir
    	    wm iconname . [utilDirTail $dir]
	    set tail [file tail $path]
	    foreach i [dir lsdirs $dir] {
		if {$i == $tail} {
		     $tree movelink $path $dir
		} else {
		    dirtreeAddDir $canvas $tree $dir $dir/$i "$i"
		}
	    }
       }
    } else {
	$tree root $path
	 set dirtree(direntry) $path
         wm iconname . [utilDirTail $path]
    }
    $tree draw
}


# remove the selected node and its subnodes from the display

proc dirtreeHideNode {canvas tree} {
    set path [dirtreeGetPath $canvas]
    if {"$path" != "" && ![$tree isroot $path]} {
        $tree rmlink $path
        $tree draw
    }
}


# Toggle the layout of the tree between vertical and horizontal

proc dirtreeToggleLayout {canvas tree} {
    set scrollincrement [utilGetConfigValue $canvas -scrollincrement]
    if {[utilGetConfigValue $tree -layout] == "horizontal"} {
        $tree config -layout vertical
    } else {
        $tree config -layout horizontal
    }
    
    # change the layout of the nodes so that the bitmap is on top for
    # vertical trees and at left for horizontal trees
    foreach i [$canvas find withtag text] {
        set dir [lindex [$canvas gettags $i] 0]
        dirtreeLayoutNode $canvas $tree $dir
        $tree nodeconfig $dir
    }
    
    $tree draw
    tree_center $tree
}


# layout the components of the given node depending on whether
# the tree is vertical or horizontal

proc dirtreeLayoutNode {canvas tree dir} {
    set text $dir:text
    set bitmap $dir:bitmap
    set list [$canvas find withtag $dir:list]
    
    if {[utilGetConfigValue $tree -layout] == "horizontal"} {
        scan [$canvas bbox $text] "%d %d %d %d" x1 y1 x2 y2
	$canvas itemconfig $bitmap -anchor se
	$canvas coords $bitmap $x1 $y2
	if {"$list" != ""} {
	    scan  [$canvas bbox $text $bitmap] "%d %d %d %d" x1 y1 x2 y2
	    $canvas itemconfig $list -anchor nw
	    $canvas coords $list $x1 $y2
	}
    } else {
        scan [$canvas bbox $bitmap] "%d %d %d %d" x1 y1 x2 y2
	$canvas itemconfig $text -anchor n
	$canvas coords $text [expr "$x1+($x2-$x1)/2"] $y2
	if {"$list" != ""} {
	    scan  [$canvas bbox $text $bitmap] "%d %d %d %d" x1 y1 x2 y2
	    $canvas itemconfig $list -anchor n
	    $canvas coords $list [expr "$x1+($x2-$x1)/2"] $y2
	}
    }
}


# display the directory tree for $dir in canvas $c


# add the dirs under $dir to the tree
 
proc dirtreeListDirs {canvas tree dir} {
    
    foreach i [dir lsdirs $dir] {
  	dirtreeAddDir $canvas $tree $dir $dir/$i "$i"
    }
}


# Edit the selected file (from the listbox $list) in 
# the editor of choice

proc dirtreeOpenFile {} {
    set file [dirtreeGetFilename]
    if {"$file" == ""} {return}
    puts "got $file"
}


# add a node to the tree (if not already there)
#
# Args: 
#	canvas	-	tree's canvas
#	tree	-	the tree
#	parent	-	parent dir
#	dir	-	child  dir
#	text	-	text for child node

proc dirtreeAddDir {canvas tree parent dir text} {
    global dirtree
    
    # don't add the node if its already there
    if [llength [$canvas find withtag $dir]] {
        return
    }
    
    # make it more obvious, which directories have subdirs
    # by making them bold and the others normal
    # (looking ahead can drag the performance down)
    set font "-Adobe-Helvetica-Bold-R-Normal--*-120-*"
    if {$dirtree(lookAhead) && ![dir hassubdirs $dir]} {
 	set font "-Adobe-Helvetica-Medium-R-Normal--*-120-*"
    }
       
    $canvas create bitmap 0 0 -bitmap "@bitmaps/dir.xbm" -tags "$dir bitmap $dir:bitmap" \
        -foreground $dirtree(bitmapColor)
    $canvas create text 0 0 -text "$text" -font $font -tags "$dir text $dir:text"
    set line [$canvas create line 0 0 0 0 -tag "line" -width 1 -capstyle round -fill $dirtree(lineColor)]
    dirtreeLayoutNode $canvas $tree $dir
    $tree addlink $parent $dir $line -border 2
}


# return true if one of the patterns in $dirtree(invisible) matches
# the given filename

proc dirtreeIgnoreFile {file} {
    global dirtree
    foreach i $dirtree(ignore) {
	if {[string match $i $file]} {
	    return "1"
	}
    }
    return "0"
}


# fill the listbox list with the files in the given dir
# (with the uninteresting files filtered out)

proc dirtreeListFiles {list dir} {
    
    foreach i [dir lsfiles $dir] {
	if [dirtreeIgnoreFile $i] {
	    continue
	}
	
	$list insert end $i
    }
}


# make the list frame for displaying the files in dir

proc dirtreeMakeListFrame {canvas tree frame dir} {
    global dirtree 
    set bg [utilGetConfigValue $canvas -bg]
    
    # make the list frame and set up resizing 
    frame $frame -borderwidth 3 -cursor bottom_right_corner
    set list $frame.list
    set scroll $frame.scroll
    scrollbar $scroll -relief sunken -command "$list yview" -width 10
    listbox $list -yscroll "$scroll set" -relief sunken -bg $bg
    pack $scroll -side right -fill y 
    pack $list -side left -expand yes -fill both
    
    # fill the list and set its size
    dirtreeListFiles $list $dir 
    
    # only allow select of one item
    tk_listboxSingleSelect $list
    
    # insert the list frame in the canvas
    $canvas create window 0 0 -tags "$dir $dir:list list" -width 3c -height 2c -window $frame
    dirtreeLayoutNode $canvas $tree $dir
    $canvas itemconfig $dir:bitmap -bitmap "@bitmaps/open_dir.xbm"
    $tree nodeconfig $dir -remove "destroy $frame" 
    dirtreeFileListBindings $canvas $tree $frame $list $scroll $dir
}


# remove the list frame for displaying the files in dir

proc dirtreeRemoveListFrame {canvas tree frame dir} {
    global dirtree 
    $canvas delete $dir:list
    destroy $frame
    $canvas itemconfig $dir:bitmap -bitmap "@bitmaps/dir.xbm"
    $tree nodeconfig $dir -remove "" -border 2
    global dirtree
    set dirtree(list) ""
    set dirtree(dir) ""
}



# generates a unique name for a widget from the given
# directory name by replacing the '.'s with '_'s

proc dirtreeUniqueName {canvas dir} {
    global dirtree
    if {![catch {set path $dirtree($canvas.$dir)}]} {
	return $path
    }
    if {[catch {incr dirtree(listboxcnt)}]} {
	set dirtree(listboxcnt) 0
    } 
    set dirtree($canvas.$dir) $canvas.list$dirtree(listboxcnt)
    return $dirtree($canvas.$dir)
}



# Display the file names in the selected directory in
# a scrolling list beneath the node

proc dirtreeShowFiles {canvas tree} {
    set id [$canvas select item]
    if {"$id" == ""} {return}
    set cur [$canvas find withtag current]
    if {"$cur" != "" && "$id" != "$cur"} {return}
    set tags [$canvas gettags $id]
    set dir [lindex $tags 0]
    
    set frame [dirtreeUniqueName $canvas $dir]
    
    # create the frame and list if not already there
    if {![llength [$canvas find withtag $dir:list]]} {
        dirtreeMakeListFrame $canvas $tree $frame $dir
    } else {
        dirtreeRemoveListFrame $canvas $tree $frame $dir
    }
    $tree draw
}


# event proc called when a list is resized

proc dirtreeResizeList {canvas tree frame list x y dir {when any}} {
    global dirtree
    
    case "$when" {
	"first" {
	    set dirtree(tlx) $x
	    set dirtree(tly) $y
	    #$frame config -cursor bottom_right_corner
	} 
	"last" {
	    #$frame config -cursor ""
	    $tree nodeconfig $dir
	    $tree draw
	}
	default {
	    set w [lindex [$canvas itemconfig $dir:list -width] 4]
	    set h [lindex [$canvas itemconfig $dir:list -height] 4]
	    set nw [expr $w+($x-$dirtree(tlx))]
	    set nh [expr $h+($y-$dirtree(tly))]
	    $canvas itemconfig $dir:list -width $nw -height $nh
	    set dirtree(tlx) $x
	    set dirtree(tly) $y
	}
    }
}


# local initialization

proc dirtreeInit {} {
    global dirtree
    
    # these 2 variables are used to keep track of the current open file list and dir
    set dirtree(dir) ""
    set dirtree(list) ""
    
    # List of files to ignore (should be an option ?)
    set dirtree(ignore) {.* *% *~ core *.BAK #* *.o}
}


# parse the command line options
#
# Usage: dirtree ?dir? ?option arg option arg?
#

proc dirtreeOptions {argv} {
    global dirtree
    
    # save options 
    set dirtree(argv) "$argv"
    
    # for error message
    set usage {
usage: dirtree ?dir? ?options...?
    	
Option              Arg Type      Description
-----------------------------------------------------------------------
-lookahead          none          display directories with subdirs in bold face
-bitmapcolor        Tk color      color of directory bitmaps
-bitmapselectcolor  Tk color      color of directory bitmaps when selected
-linecolor          Tk color      color of tree lines
-colormodel         keyword       set to "color" or "monochrome"
}
    
    # set initial values
    set dirtree(lookAhead) ""
    set dirtree(cwd) ""
    set dirtree(bitmapColor) ""
    set dirtree(bitmapSelectColor) ""
    set dirtree(lineColor) ""
    
    # parse options
    set n [llength $argv]
    for {set i 0} {$i < $n} {incr i} {
	set opt [lindex $argv $i]
	if {"[string index $opt 0]" == "-" && "$opt" != "-lookahead"} {
	    set arg [lindex $argv [incr i]]
	}
	case $opt in {
	    -lookahead		{set dirtree(lookAhead) 1}
	    -colormodel		{tk colormodel . $arg; puts stderr "color = [tk colormodel .]"}
	    -bitmapcolor	{set dirtree(bitmapColor) $arg}
	    -bitmapselectcolor	{set dirtree(bitmapSelectColor) $arg}
	    -linecolor		{set dirtree(lineColor) $arg}
	    default		{if [file isdirectory $opt] {
	     			      set dirtree(cwd) $opt
	     			 } else { 
	     			      puts stderr "$usage"
	     			      exit 1
	     			 }}
	}
    }
    
    # set any values that were not explicitly set as options
    if {"$dirtree(lookAhead)" == ""} {
        set dirtree(lookAhead) 0
    }
            
    if {"$dirtree(cwd)" == ""} {
        set dirtree(cwd) [exec pwd]
    }
    
    if {"$dirtree(bitmapColor)" == ""} {
        set dirtree(bitmapColor) red
    }
    
    if {"$dirtree(bitmapSelectColor)" == ""} {
        set dirtree(bitmapSelectColor) lightblue2
    }
    
    if {"$dirtree(lineColor)" == ""} {
        set dirtree(lineColor) grey
    }

    # set some resources
    option add *Listbox*font "-Adobe-Helvetica-Medium-R-Normal--*-100-*"

}


# ---------------------------------------------------------------------------
# main 

lappend auto_path .
wm title . "DirTree"
wm geometry . 600x400
option readfile app-defaults/Dirtree2

# local initialization
dirtreeInit

# parse the command line options
dirtreeOptions $argv

# create the main window
dirtreeMakeWindow $dirtree(cwd)

