#!/usr/bin/tclsh
package require Tk
set dir [file dirname [info script]]
tcl::tm::path add $dir
package require accordion
accordion .a -width 600 -height 500 -speed 15
pack .a -fill both -expand 1
if {$argc == 0} {
set argv [lsort -dictionary [glob -dir $dir *.tcl *.tm]]
}
foreach n $argv {
set w [frame .a.f[incr f]]
.a add $w -text "[file tail $n]"
text $w.t -yscrollcommand [list $w.vs set] -background white \
-highlightthickness 0 -relief flat -bd 4
ttk::scrollbar $w.vs -command [list $w.t yview]
pack $w.vs -side right -fill y
pack $w.t -fill both -expand 1
if {[catch {open $n} fd]} {
$w.t insert end "$fd"
} else {
$w.t insert end [read -nonewline $fd]
close $fd
}
}