--- ray/src/util/getfile3.6.tcl 1994/11/30 16:04:39 2.6 +++ ray/src/util/getfile3.6.tcl 2003/02/22 02:07:30 2.10 @@ -1,4 +1,4 @@ -# SCCSid "$SunId$ LBL" +# RCSid: $Id: getfile3.6.tcl,v 2.10 2003/02/22 02:07:30 greg Exp $ # # Usage: getfile [-win w] [-grab] [-perm] [-glob pattern] [-view proc] [-send proc] # @@ -23,6 +23,7 @@ proc getfile args { # get filename interactively set dograb 0 set curdir . set curpat * + set curfile {} set transient 1 # Get options while {[llength $args]} { @@ -60,12 +61,12 @@ proc getfile args { # get filename interactively # Create widgets catch {destroy $w} if $topwin { - toplevel $w -geometry 400x410 + toplevel $w -width 400 -height 410 wm title $w "File Picker" wm iconname $w "Files" wm minsize $w 400 300 } else { - frame $w -geometry 400x410 + frame $w -width 400 -height 410 pack $w } if $dograb { grab $w } @@ -160,7 +161,7 @@ proc getfile args { # get filename interactively proc update_dir w { # Update working directory global curdir curpat - if {"$curpat" == ""} { + if {"$curpat" == {}} { set curpat * } if {"$curdir" == {}} {set curdir {~}} @@ -172,6 +173,12 @@ proc update_dir w { # Update working directory $w.de config -foreground $oldcol } set curdir [pwd] + set offset [expr [string length $curdir] - 32] + if {$offset > 0} { + $w.de view [expr $offset + \ + [string first / [string range $curdir $offset end]] \ + + 1] + } $w.fm.fl delete 0 end set ls ../ foreach f [glob -nocomplain *] { @@ -188,7 +195,7 @@ proc update_dir w { # Update working directory } -proc set_curfile {w {sp ""}} { # change current file selection +proc set_curfile {w {sp {}}} { # change current file selection global curdir curfile set f [$w.fm.fl get [$w.fm.fl curselection]] if [string match */ $f] { @@ -196,7 +203,7 @@ proc set_curfile {w {sp ""}} { # change current file update_dir $w } else { set curfile $f - if {"$sp" > ""} { + if {"$sp" != {}} { $sp $curdir/$curfile } } @@ -205,7 +212,7 @@ proc set_curfile {w {sp ""}} { # change current file proc chk_select w { # check if current selection is file set s [$w.fm.fl curselection] - if {"$s" > "" && [file isfile [$w.fm.fl get $s]]} { + if {"$s" != {} && [file isfile [$w.fm.fl get $s]]} { $w.vi configure -state normal } else { $w.vi configure -state disabled