25 |
|
global curhelp helpfontwidth |
26 |
|
if {! [winfo exists .helpwin]} { # Set up window |
27 |
|
toplevel .helpwin |
28 |
< |
wm minsize .helpwin 400 400 |
28 |
> |
wm minsize .helpwin 500 400 |
29 |
|
wm iconbitmap .helpwin question |
30 |
< |
frame .helpwin.but -geometry 200x500 |
30 |
> |
frame .helpwin.but -geometry 150x400 |
31 |
|
pack .helpwin.but -side right -fill none -expand no |
32 |
|
label .helpwin.but.lab -textvariable curhelp(title) |
33 |
|
place .helpwin.but.lab -relx .1667 -rely 0 |
36 |
|
-text Category -menu .helpwin.but.catb.m |
37 |
|
menu .helpwin.but.catb.m |
38 |
|
place .helpwin.but.catb -relx .1667 -rely .1100 \ |
39 |
< |
-relwidth .5000 -relheight .0500 |
39 |
> |
-relwidth .5000 -relheight .0600 |
40 |
|
helplink .helpwin.but.catb help help category |
41 |
|
menubutton .helpwin.but.topb -relief raised -height 1 \ |
42 |
|
-text Topic -menu .helpwin.but.topb.m |
43 |
|
menu .helpwin.but.topb.m |
44 |
|
place .helpwin.but.topb -relx .1667 -rely .2200 \ |
45 |
< |
-relwidth .5000 -relheight .0500 |
45 |
> |
-relwidth .5000 -relheight .0600 |
46 |
|
helplink .helpwin.but.topb help help topic |
47 |
|
button .helpwin.but.srchb -text Grep -relief raised \ |
48 |
|
-height 1 -command {helpsearch $curhelp(search)} |
49 |
|
place .helpwin.but.srchb -relx .1667 -rely .3500 \ |
50 |
< |
-relwidth .5000 -relheight .0500 |
50 |
> |
-relwidth .5000 -relheight .0600 |
51 |
|
helplink .helpwin.but.srchb help navigate search |
52 |
|
entry .helpwin.but.srche -relief sunken -insertofftime 0 \ |
53 |
|
-textvariable curhelp(search) |
54 |
|
place .helpwin.but.srche -relx .1667 -rely .4200 \ |
55 |
< |
-relwidth .6667 -relheight .0500 |
55 |
> |
-relwidth .6667 -relheight .0600 |
56 |
|
bind .helpwin.but.srche <Return> {set curhelp(msg) {} |
57 |
|
helpupdate} |
58 |
|
helplink .helpwin.but.srche help navigate search |
61 |
|
button .helpwin.but.next -text Next -relief raised -height 1 \ |
62 |
|
-command {eval helphist new $curhelp(next)} |
63 |
|
place .helpwin.but.next -relx .1667 -rely .7500 \ |
64 |
< |
-relwidth .5 -relheight .0500 |
64 |
> |
-relwidth .5 -relheight .0600 |
65 |
|
helplink .helpwin.but.next help navigate next |
66 |
|
button .helpwin.but.back -text Back -relief raised -height 1 \ |
67 |
|
-command "helphist back" |
68 |
|
place .helpwin.but.back -relx .1667 -rely .6500 \ |
69 |
< |
-relwidth .5 -relheight .0500 |
69 |
> |
-relwidth .5 -relheight .0600 |
70 |
|
helplink .helpwin.but.back help navigate back |
71 |
|
button .helpwin.but.forw -text Forward -relief raised -height 1\ |
72 |
|
-command "helphist forward" |
73 |
|
place .helpwin.but.forw -relx .1667 -rely .5500 \ |
74 |
< |
-relwidth .5 -relheight .0500 |
74 |
> |
-relwidth .5 -relheight .0600 |
75 |
|
helplink .helpwin.but.forw help navigate forward |
76 |
|
button .helpwin.but.done -text Done -relief raised -height 1 \ |
77 |
|
-command "destroy .helpwin ; helpopen {}" |
78 |
|
place .helpwin.but.done -relx .1667 -rely .9000 \ |
79 |
< |
-relwidth .5 -relheight .0500 |
79 |
> |
-relwidth .5 -relheight .0600 |
80 |
|
helplink .helpwin.but.done help help done |
81 |
|
text .helpwin.txt -wrap word -width 48 -height 20 -bd 2 \ |
82 |
|
-yscrollcommand ".helpwin.sb set" -relief raised \ |
83 |
< |
-font -*-courier-medium-r-normal--18-*-*-*-*-*-iso8859-1 |
83 |
> |
-font -*-courier-medium-r-normal--14-*-*-*-*-*-iso8859-1 |
84 |
|
.helpwin.txt tag configure highlight \ |
85 |
< |
-font -*-courier-bold-r-normal--18-*-*-*-*-*-iso8859-1 |
86 |
< |
set helpfontwidth 11 |
85 |
> |
-font -*-courier-bold-r-normal--14-*-*-*-*-*-iso8859-1 |
86 |
> |
set helpfontwidth 9 |
87 |
|
scrollbar .helpwin.sb -relief flat \ |
88 |
|
-command ".helpwin.txt yview" |
89 |
|
pack .helpwin.sb -side right -fill y |
91 |
|
helplink .helpwin.sb help helpwin scroll |
92 |
|
helplink .helpwin.txt help helpwin intro |
93 |
|
tkwait visibility .helpwin |
94 |
– |
update |
94 |
|
} elseif {! [winfo ismapped .helpwin]} { # map window |
95 |
|
wm deiconify .helpwin |
96 |
|
} else { # raise window |
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 |
123 |
|
set curhelp(title) "[string toupper\ |
124 |
|
[file rootname [file tail $fname]]] HELP" |
125 |
|
wm iconname .helpwin [string tolower $curhelp(title)] |
126 |
+ |
.helpwin.txt configure -state normal |
127 |
+ |
.helpwin.txt delete 1.0 end |
128 |
+ |
.helpwin.txt insert end "Loading $fname..." |
129 |
+ |
update |
130 |
|
set curhelp(fid) [open $fname r] |
131 |
< |
set curhelp(index) {} |
129 |
< |
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 |
160 |
– |
set toplist {} |
161 |
– |
set n [llength $curhelp(index)] |
162 |
– |
for {set i 0} {$i < $n} {incr i} { |
163 |
– |
if {"[string toupper [lindex [lindex \ |
164 |
– |
$curhelp(index) $i] 0]]" == "$cat"} { |
165 |
– |
lappend toplist [lindex [lindex \ |
166 |
– |
$curhelp(index) $i] 1] |
167 |
– |
} |
168 |
– |
} |
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 \ |
197 |
< |
$curhelp(index) $i]] 0 1]} { |
198 |
< |
break |
199 |
< |
} |
200 |
< |
} |
201 |
< |
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 |
|
} |
207 |
– |
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] |
302 |
< |
seek $curhelp(fid) [lindex [lindex $curhelp(index) 0] 2] |
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) $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]*)$} \ |
322 |
|
} else { |
323 |
|
set curhelp(msg) "Not found." |
324 |
|
} |
325 |
+ |
seek $curhelp(fid) $startpos |
326 |
|
return $nmatches |
327 |
|
} |