4 # --------------------------------------------------------------------------
5 # Starting with Tcl 8.x, the BLT commands are stored in their own
6 # namespace called "blt". The idea is to prevent name clashes with
7 # Tcl commands and variables from other packages, such as a "table"
8 # command in two different packages.
10 # You can access the BLT commands in a couple of ways. You can prefix
11 # all the BLT commands with the namespace qualifier "blt::"
14 # blt::table . .g -resize both
16 # or you can import all the command into the global namespace.
18 # namespace import blt::*
20 # table . .g -resize both
22 # --------------------------------------------------------------------------
23 if { $tcl_version >= 8.0 } {
24 namespace import blt::*
25 namespace import -force blt::tile::*
27 source scripts/demo.tcl
33 image create photo bgTexture -file ./images/rain.gif
36 foreach f [glob ./images/mini-*.gif] {
37 lappend imageList [image create photo -file $f]
40 #option add *Hiertable.Tile bgTexture
41 option add *Hiertable.ScrollTile yes
42 #option add *Hiertable.Column.background grey90
43 option add *Hiertable.titleShadow { grey80 }
44 option add *Hiertable.titleFont {*-helvetica-bold-r-*-*-11-*-*-*-*-*-*-*}
46 option add *xHiertable.openCommand {
47 set path /home/gah/src/blt/%P
48 if { [file isdirectory $path] } {
50 set files [glob -nocomplain * */. ]
52 eval %W insert -at %n end $files
57 option add *xHiertable.closeCommand {
58 eval %W delete %n 0 end
61 hiertable .h -width 0\
62 -yscrollcommand { .vs set } \
63 -xscrollcommand { .hs set } \
64 -selectmode multiple \
68 .h column configure treeView -text "View"
69 .h column insert 0 mtime atime gid
70 .h column insert end nlink mode type ctime uid ino size dev
71 .h column configure uid -background \#eaeaff -font fixed
72 .h column configure mtime -hide no -bg \#ffeaea
73 .h column configure size gid nlink uid ino dev -justify right
74 .h column configure treeView -hide no -edit no
76 .h text configure -selectborderwidth 0
77 scrollbar .vs -orient vertical -command { .h yview }
78 scrollbar .hs -orient horizontal -command { .h xview }
84 proc FormatSize { size } {
87 set rem [expr $size % 1000]
88 set size [expr $size / 1000]
90 set rem [format "%03d" $rem]
92 if { $string != "" } {
93 set string "$rem,$string"
112 proc FormatMode { mode } {
115 set mode [format %o [expr $mode & 07777]]
116 set owner $modes([string index $mode 0])
117 set group $modes([string index $mode 1])
118 set world $modes([string index $mode 2])
120 return "${owner}${group}${world}"
123 table configure . c1 r1 -resize none
124 image create photo fileImage -file images/stopsign.gif
125 proc DoFind { dir path } {
126 global fileList count
130 foreach f [lsort [glob -nocomplain *]] {
131 set entry [file join $path $f]
132 if { [catch { file stat $entry info }] != 0 } {
133 lappend fileList $entry
136 if { $info(type) == "file" } {
137 set info(type) @fileImage
142 set info(mtime) [clock format $info(mtime) -format "%b %d, %Y"]
143 set info(atime) [clock format $info(atime) -format "%b %d, %Y"]
144 set info(ctime) [clock format $info(ctime) -format "%b %d, %Y"]
145 set info(size) [FormatSize $info(size)]
146 set info(mode) [FormatMode $info(mode)]
147 lappend fileList $entry -data [array get info]
150 if { [file isdirectory $f] } {
158 global fileList count
160 catch { file stat $dir info }
162 lappend fileList $dir -data [array get info]
167 proc GetAbsolutePath { dir } {
175 set top [GetAbsolutePath ..]
178 .h configure -separator "/" -trim $trim
181 .h entry configure root -label [file tail [GetAbsolutePath $top]]
182 .h configure -bg grey90
183 regsub -all {\.\./*} [Find $top] {} fileList
184 puts "$count entries"
185 eval .h insert end $fileList
186 .h configure -bg white
190 set nodes [.h find -glob -name *.c]
191 eval .h entry configure $nodes -foreground green4
192 set nodes [.h find -glob -name *.h]
193 eval .h entry configure $nodes -foreground cyan4
194 set nodes [.h find -glob -name *.o]
195 eval .h entry configure $nodes -foreground red4
199 bind .h <ButtonPress-3> { .h text get %x %y ; focus .h.edit }
201 .h column bind all <ButtonRelease-3> {
202 %W configure -flat no
205 proc SortColumn { column } {
206 set old [.h sort cget -column]
208 if { "$old" == "$column" } {
209 set decreasing [.h sort cget -decreasing]
210 set decreasing [expr !$decreasing]
212 .h sort configure -decreasing $decreasing -column $column
213 .h configure -flat yes
220 foreach column [.h column names] {
221 .h column configure $column -command [list SortColumn $column]