diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2001-10-29 16:42:20 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2001-10-29 16:42:20 (GMT) |
commit | ae78f51281c62b80a04f7fac74514e77c50d414f (patch) | |
tree | adec4fe25f8991549af8fd2b782ed2837c84ea92 /library/demos/browse | |
parent | 0f7f254616e3bbed160bf140e85cce32d98f30bc (diff) | |
download | tk-ae78f51281c62b80a04f7fac74514e77c50d414f.zip tk-ae78f51281c62b80a04f7fac74514e77c50d414f.tar.gz tk-ae78f51281c62b80a04f7fac74514e77c50d414f.tar.bz2 |
More demo upgrades derived from 8.3.4
Diffstat (limited to 'library/demos/browse')
-rw-r--r-- | library/demos/browse | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/library/demos/browse b/library/demos/browse index d3f55e3..cd9e09a 100644 --- a/library/demos/browse +++ b/library/demos/browse @@ -1,13 +1,13 @@ #!/bin/sh # the next line restarts using wish \ -exec wish "$0" "$@" +exec wish8.4 "$0" ${1+"$@"} || exec wish "$0" ${1+"$@"} # browse -- # This script generates a directory browser, which lists the working # directory and allows you to open files or subdirectories by # double-clicking. # -# RCS: @(#) $Id: browse,v 1.2 1998/09/14 18:23:27 stanton Exp $ +# RCS: @(#) $Id: browse,v 1.3 2001/10/29 16:42:20 dkf Exp $ # Create a scrollbar on the right side of the main window and a listbox # on the left side. @@ -24,29 +24,35 @@ wm minsize . 1 1 # the file is a regular file then the Mx editor is invoked to display # the file. +set browseScript [file join [pwd] $argv0] proc browse {dir file} { - global env + global env browseScript if {[string compare $dir "."] != 0} {set file $dir/$file} - if [file isdirectory $file] { - exec browse $file & - } else { - if [file isfile $file] { - if [info exists env(EDITOR)] { + switch [file type $file] { + directory { + exec [info nameofexecutable] $browseScript $file & + } + file { + if {[info exists env(EDITOR)]} { eval exec $env(EDITOR) $file & } else { exec xedit $file & } - } else { + } + default { 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). +# Fill the listbox with a list of all the files in the directory. -if $argc>0 {set dir [lindex $argv 0]} else {set dir "."} -foreach i [exec ls -a $dir] { +if {$argc>0} {set dir [lindex $argv 0]} else {set dir "."} +foreach i [lsort [glob * .* *.*]] { + if {[file type $i] eq "directory"} { + # Safe to do since it is still a directory. + append i / + } .list insert end $i } @@ -54,3 +60,7 @@ foreach i [exec ls -a $dir] { bind all <Control-c> {destroy .} bind .list <Double-Button-1> {foreach i [selection get] {browse $dir $i}} + +# Local Variables: +# mode: tcl +# End: |