#!/usr/bin/wish

# This program is part of Geoduck, a set of graphical user
# interfaces for UNIX programs.
# Copyright (C) 2002 Allen B. Downey
#
# 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.
#
# For a copy of the GNU General Public License, go to
# www.gnu.org/copyleft/gpl.html
# or write to the Free Software Foundation, Inc.
# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
#
# Contact the author: me@allendowney.com

set dir [file dirname [info script]]
source [file join $dir geoduck.tcl]

proc getCommand {} {
    global st widget

    set cmd "ls [getFlags]"
    append cmd " " [enValue en_args]
}

proc test {} {

    # check the width
    set width [getEntry en_width]
    if {$width != ""} {
	catch {config text -width $width}
    }

    # execute the command and put the result in the text window
    set cmd [getEntry en_command]
    fillText text [execCatch $cmd]
}

proc execute {} {
    global env widget
    set cmd [getEntry en_command]
    puts $cmd
    puts [execCatch $cmd]
}


# COLUMN 1

topFrame
set st(autotest) 1

fr

fr -side left -padx 5 

la  "Which files or dirs?"
fr
en 15 en_args "" browse
endfr

la ""
fr -side left

la  "Include..."
cr  "backup (~) files?"         cr_backup     -B
cr  "directory contents?"       cr_dir        -d
cb  "files in subdirectories?"  cb_subdir      -R

la ""
la  "List dotfiles?"
rb  "omit"                      rb_dotfiles  omit    ""
rb  "include"                   rb_dotfiles  all     -a
rb  "all except . and .."       rb_dotfiles  most    -A

la  ""
la  "Exclude files that match:"
en  10  en_ignore    -I

endfr

# COLUMN 2

frSpace -side left -padx 5
fr -side left

la  "Format"
rb  "single column"       rb_format     single       
rb  "long"                rb_format     long        -l
rb  "long (full dates)"   rb_format     fulldate    --full-time
rb  "multi-column"        rb_format     multi       -C
rb  "horizontal"          rb_format     horiz       -x
rb  "with commas"         rb_format     comma       -m

la ""
la  "What info?"
cr  "group ids?"            cr_group          -G
cb  "size in blocks?"       cb_size            -s
cb  "inodes?"               cb_inode           -i
cb  "numeric ids?"          cb_nids            -n

endfr
endfr

# COLUMN 3

fr -side left -padx 5
la  "Sort by?"
rb  "name"             rb_sort     name        ""
rb  "directory order"  rb_sort     directory   -U
rb  "size"             rb_sort     size        -S
rb  "mod time"         rb_sort     modtime     -t
rb  "access time"      rb_sort     acctime     -u
rb  "ctime"            rb_sort     sort_ctime  -c
rb  "extension"        rb_sort     extension   -X
rb  "version"          rb_sort     version     -v

la  ""
cb  "reverse order?"   cb_reverse           -r

la  ""
la  "Show which times?"
rb  "access time"           rb_time       access
rb  "ctime"                 rb_time       time_ctime      --time=ctime

endfr

# COLUMN 4

fr -side left  -padx 5

la  "Sizes"
rb  "bytes"             rb_size   byte     
rb  "kilobytes"         rb_size   kilo      -k
rb  "human readable"    rb_size   human     -h
rb  "human (base 10)"   rb_size   base10    --si
rb  "blocksize:"        rb_size   block    {getEntry en_block --block-size=}
en  10  en_block

la  ""
la  "Label files?"
rb  "none"               rb_label   none  
rb  "file type"          rb_label   filetype   -p
rb  "classify all"       rb_label   classify   -F

la  ""
cb  "Names in quotes?"           cb_quotes          -Q
cb  "Show links as files?"       cb_links           -L

endfr

# COLUMN 5

fr -side left  -padx 5


fr
la  "Control chars:"
rb  "show"                 rb_control    show     ""
rb  "hide"                 rb_control    hide     -q
rb  "show in octal"        rb_control    octal    -b
endfr

la  ""
la  "Screen width"
en  15 en_width      -w

la  ""
la  "Tab size"
en  15 en_tabsize    -T

la ""
la ""
la ""
colorMenu

endfr
endfr

# ROW 3
bottomFrame

bind . <Return> "+test"

showCommand
