102 |
|
} |
103 |
|
|
104 |
|
proc helpopen fname { # open the named help file |
105 |
< |
global curhelp helplib |
105 |
> |
global curhelp helpindex helplib |
106 |
|
if {"$fname" == "$curhelp(file)"} {return} |
107 |
|
if {"$curhelp(file)" != {}} { |
108 |
|
close $curhelp(fid) |
109 |
< |
unset curhelp |
109 |
> |
unset curhelp helpindex |
110 |
|
} |
111 |
|
if {[set curhelp(file) $fname] == {}} {return} |
112 |
|
# Complete file name as required |
128 |
|
.helpwin.txt insert end "Loading $fname..." |
129 |
|
update |
130 |
|
set curhelp(fid) [open $fname r] |
131 |
< |
set curhelp(index) {} |
132 |
< |
set catlist {} |
131 |
> |
set curhelp(catlist) {} |
132 |
|
while {[gets $curhelp(fid) li] >= 0} { |
133 |
|
if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \ |
134 |
|
$li dummy cat top] { |
135 |
< |
lappend curhelp(index) "$cat $top [tell $curhelp(fid)]" |
136 |
< |
if {[lsearch -exact $catlist $cat] < 0} { |
137 |
< |
lappend catlist $cat |
135 |
> |
lappend helpindex([string toupper $cat]) $top |
136 |
> |
set helpindex([string toupper $cat,$top]) \ |
137 |
> |
[tell $curhelp(fid)] |
138 |
> |
if {[lsearch -exact $curhelp(catlist) $cat] < 0} { |
139 |
> |
lappend curhelp(catlist) $cat |
140 |
|
} |
141 |
|
} |
142 |
|
} |
143 |
|
.helpwin.but.catb.m delete 0 last |
144 |
< |
foreach cat $catlist { |
144 |
> |
foreach cat $curhelp(catlist) { |
145 |
|
.helpwin.but.catb.m add command -label $cat \ |
146 |
|
-command "helphist new $cat intro" |
147 |
|
} |
153 |
|
} |
154 |
|
|
155 |
|
proc helpgoto {cat top} { # find selected category and topic |
156 |
< |
global curhelp |
156 |
> |
global curhelp helpindex |
157 |
|
# Capitalize "just in case" |
158 |
|
set cat [string toupper $cat] |
159 |
|
set top [string toupper $top] |
161 |
|
set curhelp(topic) $top |
162 |
|
if {"$cat" != "$curhelp(category)"} { |
163 |
|
set curhelp(category) $cat |
163 |
– |
set toplist {} |
164 |
– |
set n [llength $curhelp(index)] |
165 |
– |
for {set i 0} {$i < $n} {incr i} { |
166 |
– |
if {"[string toupper [lindex [lindex \ |
167 |
– |
$curhelp(index) $i] 0]]" == "$cat"} { |
168 |
– |
lappend toplist [lindex [lindex \ |
169 |
– |
$curhelp(index) $i] 1] |
170 |
– |
} |
171 |
– |
} |
164 |
|
.helpwin.but.topb.m delete 0 last |
165 |
< |
foreach top $toplist { |
165 |
> |
foreach top $helpindex($cat) { |
166 |
|
.helpwin.but.topb.m add command -label $top \ |
167 |
|
-command "helphist new \$curhelp(category) $top" |
168 |
|
} |
171 |
|
} |
172 |
|
|
173 |
|
proc helpupdate {} { # update help text window |
174 |
< |
global curhelp helpfontwidth |
174 |
> |
global curhelp helpindex helpfontwidth |
175 |
|
# Print category and topic |
176 |
|
set linelen [expr "[winfo width .helpwin.txt] / $helpfontwidth - 1"] |
177 |
|
.helpwin.txt configure -state normal |
186 |
|
# Search for it in file |
187 |
|
if {"$curhelp(category) $curhelp(topic)" != |
188 |
|
"[string toupper $curhelp(next)]"} { |
189 |
< |
for {set i [llength $curhelp(index)]} {[incr i -1] >= 0} {} { |
190 |
< |
if {"$curhelp(category) $curhelp(topic)" == |
191 |
< |
[lrange [string toupper [lindex \ |
200 |
< |
$curhelp(index) $i]] 0 1]} { |
201 |
< |
break |
202 |
< |
} |
203 |
< |
} |
204 |
< |
if {$i < 0} { |
189 |
> |
if [info exists helpindex($curhelp(category),$curhelp(topic))] { |
190 |
> |
seek $curhelp(fid) $helpindex($curhelp(category),$curhelp(topic)) |
191 |
> |
} else { |
192 |
|
.helpwin.txt insert end "\nNo such help topic." |
193 |
|
.helpwin.txt configure -state disabled |
194 |
|
return ".$curhelp(category).$curhelp(topic) not found\ |
195 |
|
in $curhelp(file)" |
196 |
|
} |
210 |
– |
seek $curhelp(fid) [lindex [lindex $curhelp(index) $i] 2] |
197 |
|
} |
198 |
|
# Load help text into our window |
199 |
|
set linepos 0 |
291 |
|
} |
292 |
|
|
293 |
|
proc helpsearch word { # search for occurances of the given word |
294 |
< |
global curhelp |
294 |
> |
global curhelp helpindex |
295 |
|
if {"$curhelp(search)" == {}} { |
296 |
|
set curhelp(msg) "No pattern." |
297 |
|
return 0 |
298 |
|
} |
299 |
|
set nmatches 0 |
300 |
< |
set cat [lindex [lindex $curhelp(index) 0] 0] |
301 |
< |
set top [lindex [lindex $curhelp(index) 0] 1] |
300 |
> |
set cat [lindex $curhelp(catlist) 0] |
301 |
> |
set top [lindex $helpindex([string toupper $cat]) 0] |
302 |
|
set startpos [tell $curhelp(fid)] |
303 |
< |
seek $curhelp(fid) [lindex [lindex $curhelp(index) 0] 2] |
303 |
> |
seek $curhelp(fid) $helpindex([string toupper $cat,$top]) |
304 |
|
set foundmatch 0 |
305 |
|
while {[gets $curhelp(fid) li] >= 0} { |
306 |
|
if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \ |