4 set filename [lindex $argv 0]
7 # Read the file looking for command definitions
13 while {[gets $f buf] >= 0} {
14 if {[string match "~~*" $buf]} {
15 if {[string match "*:*" $prev]} {
18 set lines [linsert $lines end-1 "\[\[$target\]\]"]
22 foreach cmd [split $prev ":,"] {
23 set cmd [string trim $cmd]
24 if {[regexp {^[a-z.]+$} $cmd]} {
25 lappend commands [list $cmd $target]
26 set cdict($cmd) $target
35 # Build the command index in the list: $index
36 lappend index {[frame="none",grid="none"]}
37 lappend index {|=========================}
40 foreach command [lsort $commands] {
41 lassign $command cmd target
43 append row "|<<$target,*`$cmd`*>> "
55 lappend index {|=========================}
57 # Map all `cmd` to <<$target,`cmd`>>
59 foreach c [array names cdict] {
60 lappend mapping `$c` <<$cdict($c),*`$c`*>>
61 lappend mapping "`$c " "<<$cdict($c),*`$c`*>> `"
64 # And the command index
65 lappend mapping @INSERTINDEX@ [join $index \n]
69 puts [string map $mapping $line]