summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--library/demos/browse36
-rw-r--r--library/demos/hello6
3 files changed, 34 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 4e1dbdd..9491f0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2001-10-29 Donal K. Fellows <fellowsd@cs.man.ac.uk>
+ * library/demos/browse: Changes up-ported from core-8-3-1-branch
+ to make the script much more robust, particularly when neither the
+ current version of wish or the script are on the path.
+
+ * library/demos/hello: Added emacs trailing tag-line.
+
* library/demos/tcolor: Changes up-ported from core-8-3-1-branch
to make the script compliant with current good practise, as well
as extensive use of the new labelframe widget.
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:
diff --git a/library/demos/hello b/library/demos/hello
index c6bd8c8..ac5cdff 100644
--- a/library/demos/hello
+++ b/library/demos/hello
@@ -6,7 +6,7 @@ exec wish "$0" "$@"
# Simple Tk script to create a button that prints "Hello, world".
# Click on the button to terminate the program.
#
-# RCS: @(#) $Id: hello,v 1.2 1998/09/14 18:23:28 stanton Exp $
+# RCS: @(#) $Id: hello,v 1.3 2001/10/29 16:42:20 dkf Exp $
#
# The first line below creates the button, and the second line
# asks the packer to shrink-wrap the application's main window
@@ -16,3 +16,7 @@ button .hello -text "Hello, world" -command {
puts stdout "Hello, world"; destroy .
}
pack .hello
+
+# Local Variables:
+# mode: tcl
+# End: