Hi!
I managed to make the following out of an example of the blt demos:
#!bin/sh
#exec wish ${1+"$@"}
package require BWidget
package require BLT
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
set command [list tar -tvf tutu.tar]
proc InsertText { string tag } {
.text insert end "$tag: " "" $string $tag
update idletasks
}
proc DisplayOutput { name1 name2 how } {
upvar #0 $name1 arr
InsertText "$arr($name2)\n" stdout
set arr($name2) {}
}
proc DisplayErrors { name1 name2 how } {
upvar #0 $name1 arr
InsertText "$arr($name2)\n" stderr
set arr($name2) {}
}
trace variable results(stdout) w DisplayOutput
trace variable results(stderr) w DisplayErrors
# Create widgets
text .text
.text tag configure stdout -font -*-Helvetica-Bold-R-*-*-18-*-*-*-*-*-*-* -foreground green2
.text tag configure stderr -font -*-Helvetica-Medium-O-*-*-18-*-*-*-*-*-*-* -foreground red2
pack .text -fill both
.text delete 1.0 end
set results(status) {}
eval "bgexec results(status) -lasterror results(stderr) -lastoutput results(stdout) $command &"
I understand most of it except for
"trace variable results(stdout) w DisplayOutput"
DisplayOutput has three parameters:
"proc DisplayOutput { name1 name2 how }"
what does this do?
"upvar #0 $name1 arr"
and in
"InsertText "$arr($name2)\n" stdout
set arr($name2) {}"
how are name1, name2 and how been updated?
Thanks!
I managed to make the following out of an example of the blt demos:
#!bin/sh
#exec wish ${1+"$@"}
package require BWidget
package require BLT
if { $tcl_version >= 8.0 } {
namespace import blt::*
namespace import -force blt::tile::*
}
set command [list tar -tvf tutu.tar]
proc InsertText { string tag } {
.text insert end "$tag: " "" $string $tag
update idletasks
}
proc DisplayOutput { name1 name2 how } {
upvar #0 $name1 arr
InsertText "$arr($name2)\n" stdout
set arr($name2) {}
}
proc DisplayErrors { name1 name2 how } {
upvar #0 $name1 arr
InsertText "$arr($name2)\n" stderr
set arr($name2) {}
}
trace variable results(stdout) w DisplayOutput
trace variable results(stderr) w DisplayErrors
# Create widgets
text .text
.text tag configure stdout -font -*-Helvetica-Bold-R-*-*-18-*-*-*-*-*-*-* -foreground green2
.text tag configure stderr -font -*-Helvetica-Medium-O-*-*-18-*-*-*-*-*-*-* -foreground red2
pack .text -fill both
.text delete 1.0 end
set results(status) {}
eval "bgexec results(status) -lasterror results(stderr) -lastoutput results(stdout) $command &"
I understand most of it except for
"trace variable results(stdout) w DisplayOutput"
DisplayOutput has three parameters:
"proc DisplayOutput { name1 name2 how }"
what does this do?
"upvar #0 $name1 arr"
and in
"InsertText "$arr($name2)\n" stdout
set arr($name2) {}"
how are name1, name2 and how been updated?
Thanks!