ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/gethelp3.6.tcl
(Generate patch)

Comparing ray/src/util/gethelp3.6.tcl (file contents):
Revision 2.2 by greg, Fri Oct 28 10:02:17 1994 UTC vs.
Revision 2.5 by greg, Fri Oct 28 20:14:44 1994 UTC

# Line 24 | Line 24 | set curhelp(file) {}
24   proc gethelp {helpfile category topic} {        # Open help window
25          global curhelp helpfontwidth
26          if {! [winfo exists .helpwin]} {                # Set up window
27 <                toplevel .helpwin
28 <                wm minsize .helpwin 450 350
27 >                toplevel .helpwin -cursor top_left_arrow
28 >                wm minsize .helpwin 500 400
29                  wm iconbitmap .helpwin question
30 <                frame .helpwin.but -geometry 150x350
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
# Line 36 | Line 36 | proc gethelp {helpfile category topic} {       # Open help w
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
# Line 61 | Line 61 | proc gethelp {helpfile category topic} {       # Open help w
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 \
# Line 102 | Line 102 | proc gethelp {helpfile category topic} {       # Open help w
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
# Line 128 | Line 128 | proc helpopen fname {                  # open the named help file
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          }
# Line 152 | Line 153 | proc helpopen fname {                  # open the named help file
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]
# Line 160 | Line 161 | proc helpgoto {cat top} {              # find selected category an
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                  }
# Line 179 | Line 171 | proc helpgoto {cat top} {              # find selected category an
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
# Line 194 | Line 186 | proc helpupdate {} {                   # update help text window
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
# Line 305 | Line 291 | proc helphist {op args} {              # access help history list
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]*)$} \
# Line 335 | Line 322 | proc helpsearch word {         # search for occurances of the
322          } else {
323                  set curhelp(msg) "Not found."
324          }
325 +        seek $curhelp(fid) $startpos
326          return $nmatches
327   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines