ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/getfile3.6.tcl
(Generate patch)

Comparing ray/src/util/getfile3.6.tcl (file contents):
Revision 2.2 by greg, Fri Oct 28 10:43:36 1994 UTC vs.
Revision 2.8 by greg, Thu Dec 1 10:14:56 1994 UTC

# Line 1 | Line 1
1   # SCCSid "$SunId$ LBL"
2   #
3 < # Usage: getfile [-win w] [-perm] [-glob pattern] [-view proc] [-send proc]
3 > # Usage: getfile [-win w] [-grab] [-perm] [-glob pattern] [-view proc] [-send proc]
4   #
5   # Create a dialog box (in window w if given) to get file name.
6 + # If -grab option is given, then getfile does a local grab on its window.
7   # Normally, a single file name and return as value.
8   # If perm switch is given, keep window up for multiple file entries.
9   # If pattern is given, start with list of all the specified files,
# Line 19 | Line 20 | proc getfile args {            # get filename interactively
20          # Set defaults
21          set w .fpwin
22          set topwin 1
23 +        set dograb 0
24          set curdir .
25          set curpat *
26 +        set curfile {}
27          set transient 1
28          # Get options
29          while {[llength $args]} {
# Line 30 | Line 33 | proc getfile args {            # get filename interactively
33                                  set topwin 0
34                                  set args [lreplace $args 1 1]
35                                  }
36 +                        -grab {
37 +                                set dograb 1
38 +                                }
39                          -perm* {
40                                  set transient 0
41                                  }
# Line 63 | Line 69 | proc getfile args {            # get filename interactively
69                  frame $w -geometry 400x410
70                  pack $w
71          }
72 +        if $dograb { grab $w }
73 +        $w configure -cursor top_left_arrow
74          label $w.dt -text Directory:
75 <        place $w.dt -relx .0625 -rely .03125 -relwidth .15625 -relheight .0625
75 >        place $w.dt -relx .025 -rely .03125
76          helplink $w.dt file directory intro
77          button $w.ls -text List -command "update_dir $w"
78 <        place $w.ls -relx .0625 -rely .125 -relwidth .125 -relheight .0625
78 >        place $w.ls -relx .025 -rely .125 -relwidth .15 -relheight .0625
79          helplink $w.ls file directory list
80          entry $w.de -textvariable curdir -relief sunken
81          place $w.de -relx .25 -rely .03125 -relwidth .6875 -relheight .0625
# Line 95 | Line 103 | proc getfile args {            # get filename interactively
103          } else {
104                  bind $w.fm.fl <Double-Button-1> "set_curfile $w"
105                  label $w.fl -text File:
106 <                place $w.fl -relx .10625 -rely .875 \
99 <                                -relwidth .10625 -relheight .0625
106 >                place $w.fl -relx .10625 -rely .875
107                  entry $w.fn -relief sunken -textvariable curfile
108                  place $w.fn -relx .25 -rely .875 \
109                                  -relwidth .6875 -relheight .0625
# Line 110 | Line 117 | proc getfile args {            # get filename interactively
117          }
118          if {$transient != [info exists sendproc]} {
119                  button $w.ok -text OK -command "destroy $w"
120 <                place $w.ok -relx .0625 -rely .28125 \
121 <                                -relwidth .125 -relheight .0625
120 >                place $w.ok -relx .025 -rely .28125 \
121 >                                -relwidth .15 -relheight .0625
122          }
123          if {$transient || [info exists sendproc]} {
124                  button $w.cancel -text Cancel \
125                                  -command "destroy $w; unset curdir"
126 <                place $w.cancel -relx .0625 -rely .375 \
127 <                                -relwidth .125 -relheight .0625
126 >                place $w.cancel -relx .025 -rely .375 \
127 >                                -relwidth .15 -relheight .0625
128          }
129          if [info exists viewproc] {
130                  button $w.vi -text View -state disabled \
131                  -command "$viewproc \[$w.fm.fl get \[$w.fm.fl curselection\]\]"
132 <                place $w.vi -relx .0625 -rely .46875 \
133 <                                -relwidth .125 -relheight .0625
132 >                place $w.vi -relx .025 -rely .46875 \
133 >                                -relwidth .15 -relheight .0625
134                  bind $w.fm.fl <ButtonRelease-1> "+chk_select $w"
135                  helplink $w.vi file file view
136          }
# Line 154 | Line 161 | proc getfile args {            # get filename interactively
161  
162   proc update_dir w {                     # Update working directory
163          global curdir curpat
164 <        if {"$curpat" == ""} {
164 >        if {"$curpat" == {}} {
165                  set curpat *
166          }
167 +        if {"$curdir" == {}} {set curdir {~}}
168          if [catch {cd $curdir} curdir] {
169                  set oldcol [lindex [$w.de config -foreground] 4]
170                  $w.de config -foreground Red
# Line 165 | Line 173 | proc update_dir w {                    # Update working directory
173                  $w.de config -foreground $oldcol
174          }
175          set curdir [pwd]
176 +        set offset [expr [string length $curdir] - 32]
177 +        if {$offset > 0} {
178 +                $w.de view [expr $offset + \
179 +                        [string first / [string range $curdir $offset end]] \
180 +                                + 1]
181 +        }
182          $w.fm.fl delete 0 end
183          set ls ../
184 <        foreach f [glob *] {
184 >        foreach f [glob -nocomplain *] {
185                  if [file isdirectory $f] {
186                          lappend ls $f/
187                  }
# Line 181 | Line 195 | proc update_dir w {                    # Update working directory
195   }
196  
197  
198 < proc set_curfile {w {sp ""}} {          # change current file selection
198 > proc set_curfile {w {sp {}}} {          # change current file selection
199          global curdir curfile
200          set f [$w.fm.fl get [$w.fm.fl curselection]]
201          if [string match */ $f] {
# Line 189 | Line 203 | proc set_curfile {w {sp ""}} {         # change current file
203                  update_dir $w
204          } else {
205                  set curfile $f
206 <                if {"$sp" > ""} {
206 >                if {"$sp" != {}} {
207                          $sp $curdir/$curfile
208                  }
209          }
# Line 198 | Line 212 | proc set_curfile {w {sp ""}} {         # change current file
212  
213   proc chk_select w {                     # check if current selection is file
214          set s [$w.fm.fl curselection]
215 <        if {"$s" > "" && [file isfile [$w.fm.fl get $s]]} {
215 >        if {"$s" != {} && [file isfile [$w.fm.fl get $s]]} {
216                  $w.vi configure -state normal
217          } else {
218                  $w.vi configure -state disabled

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines