Parent: the name of the parent node. The topmost node is 'root' Node: The name of this node, must be unique over the whole file. File: (optional) the absolute path and file name to 'watch'Example of such a .cfg file:
Parent: root Node: Config Parent: Config Node: .bash_login File: /home/n00b3/.bash_login Parent: Config Node: .xinitrc File: /home/n00b3/.xinitrcThe program itself is very very simple. No bells and whistles because major focus was a simple example on some BWidgets. It can be extended with menu, toolbar and statusline showing the filename with a BWidget::MainFrame. The simple showing of file contents in a text widget can be extended to become a text editor. The tree nodes should be made drag-and-drop'able to reorganize and save them like one of those two pane outliners. The possibilities are infinite
package require BWidget
set dirname [file dirname [info script $argv0]]
set prgname [file rootname [info script $argv0]]
set filename [file join $dirname $prgname.cfg]
puts "open $filename"
set infile [open $filename]
set pw [PanedWindow .pw]
set pf [$pw add]
set tf [$pw add]
pack $pw -expand 1 -fill both
set sw [ScrolledWindow $pf.sw]
set tw [ScrolledWindow $tf.tw]
pack $sw -expand 1 -fill both
pack $tw -expand 1 -fill both
set swt [Tree $sw.t]
pack $swt
$sw setwidget $swt
set t [text $tf.t -wrap none]
pack $t
$tw setwidget $t
update
proc data'show {args} {
$::t delete 1.0 end
set filename [$::swt itemcget [lindex $args 0] -data]
if {[string equal $filename ""]} {return}
set data [read [open $filename]]
$::t insert end $data
}
while 1 {
unset -nocomplain parent node file
if {[eof $infile]} {break}
while {[gets $infile line] > 0} {
regexp {Parent:\s+(.+)$} $line -> parent
regexp {Node:\s+(.+)$} $line -> node
regexp {File:\s+(.+)$} $line -> file
}
if {[info exists file]} {
$::swt insert end $parent $node -text $node -data $file
} else {
$::swt insert end $parent $node -text $node
}
}
$swt bindText <1> +data'showCategory Widget

