#!/usr/prac/se/hush/bin/hush -f
#
scrollbar .scroll -command ".list yview"
listbox .list -yscroll ".scroll set" -relief raised -geometry 20x20
pack append . .scroll {right filly} .list {left expand fill}


proc browse {dir file} {
    global env
    if {[string compare $dir "."] != 0} {set file $dir/$file}
    if [file isdirectory $file] {
	exec browse $file &
    } else {
	if [file isfile $file] {
		exec $file &
	} else {
	    puts stdout "\"$file\" isn't a directory or regular file"
	}
    }
}

# Fill the listbox with a list of all the files in the directory (run
# the "ls" command to get that information).

if $argc>0 {set dir [lindex $argv 0]} else {set dir "."}
set x "[glob *.out]"
foreach i [glob *.out] {
    .list insert end $i
}

# Set up bindings for the browser.

bind .list <Control-q> {destroy .}
bind .list <Control-c> {destroy .}
focus .list
bind .list <Double-Button-1> {foreach i [selection get] {browse $dir $i}}
