summaryrefslogtreecommitdiffstats
path: root/library/demos
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2001-10-29 16:42:20 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2001-10-29 16:42:20 (GMT)
commitae78f51281c62b80a04f7fac74514e77c50d414f (patch)
treeadec4fe25f8991549af8fd2b782ed2837c84ea92 /library/demos
parent0f7f254616e3bbed160bf140e85cce32d98f30bc (diff)
downloadtk-ae78f51281c62b80a04f7fac74514e77c50d414f.zip
tk-ae78f51281c62b80a04f7fac74514e77c50d414f.tar.gz
tk-ae78f51281c62b80a04f7fac74514e77c50d414f.tar.bz2
More demo upgrades derived from 8.3.4
Diffstat (limited to 'library/demos')
-rw-r--r--library/demos/browse36
-rw-r--r--library/demos/hello6
2 files changed, 28 insertions, 14 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:
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: