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.3 by greg, Fri Oct 28 17:17:20 1994 UTC vs.
Revision 2.6 by greg, Sun Oct 30 09:05:09 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
27 >                toplevel .helpwin -cursor top_left_arrow
28                  wm minsize .helpwin 500 400
29                  wm iconbitmap .helpwin question
30                  frame .helpwin.but -geometry 150x400
# 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 122 | Line 122 | proc helpopen fname {                  # open the named help file
122          wm title .helpwin $fname
123          set curhelp(title) "[string toupper\
124                          [file rootname [file tail $fname]]]  HELP"
125 +        set ifile [file rootname $fname].ndx
126          wm iconname .helpwin [string tolower $curhelp(title)]
127          .helpwin.txt configure -state normal
128          .helpwin.txt delete 1.0 end
129          .helpwin.txt insert end "Loading $fname..."
130          update
131          set curhelp(fid) [open $fname r]
132 <        set curhelp(index) {}
133 <        set catlist {}
134 <        while {[gets $curhelp(fid) li] >= 0} {
135 <                if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \
136 <                                $li dummy cat top] {
137 <                        lappend curhelp(index) "$cat $top [tell $curhelp(fid)]"
138 <                        if {[lsearch -exact $catlist $cat] < 0} {
139 <                                lappend catlist $cat
132 >        if {! [file exists $ifile] ||
133 >                        [file mtime $fname] > [file mtime $ifile]} {
134 >                set curhelp(catlist) {}
135 >                while {[gets $curhelp(fid) li] >= 0} {
136 >                        if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \
137 >                                        $li dummy cat top] {
138 >                                lappend helpindex([string toupper $cat]) $top
139 >                                set helpindex([string toupper $cat,$top]) \
140 >                                                [tell $curhelp(fid)]
141 >                                if {[lsearch -exact $curhelp(catlist) $cat] < 0} {
142 >                                        lappend curhelp(catlist) $cat
143 >                                }
144                          }
145                  }
146 +                if {! [catch {set fi [open $ifile w]}]} {
147 +                        writevars $fi {curhelp(catlist) helpindex}
148 +                        close $fi
149 +                        catch {exec chmod 666 $ifile}
150 +                }
151 +        } else {
152 +                source $ifile
153          }
154          .helpwin.but.catb.m delete 0 last
155 <        foreach cat $catlist {
155 >        foreach cat $curhelp(catlist) {
156                  .helpwin.but.catb.m add command -label $cat \
157                                  -command "helphist new $cat intro"
158          }
# Line 152 | Line 164 | proc helpopen fname {                  # open the named help file
164   }
165  
166   proc helpgoto {cat top} {               # find selected category and topic
167 <        global curhelp
167 >        global curhelp helpindex
168          # Capitalize "just in case"
169          set cat [string toupper $cat]
170          set top [string toupper $top]
# Line 160 | Line 172 | proc helpgoto {cat top} {              # find selected category an
172          set curhelp(topic) $top
173          if {"$cat" != "$curhelp(category)"} {
174                  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                }
175                  .helpwin.but.topb.m delete 0 last
176 <                foreach top $toplist {
176 >                foreach top $helpindex($cat) {
177                          .helpwin.but.topb.m add command -label $top \
178                                  -command "helphist new \$curhelp(category) $top"
179                  }
# Line 179 | Line 182 | proc helpgoto {cat top} {              # find selected category an
182   }
183  
184   proc helpupdate {} {                    # update help text window
185 <        global curhelp helpfontwidth
185 >        global curhelp helpindex helpfontwidth
186          # Print category and topic
187          set linelen [expr "[winfo width .helpwin.txt] / $helpfontwidth - 1"]
188          .helpwin.txt configure -state normal
# Line 194 | Line 197 | proc helpupdate {} {                   # update help text window
197          # Search for it in file
198          if {"$curhelp(category) $curhelp(topic)" !=
199                          "[string toupper $curhelp(next)]"} {
200 <                for {set i [llength $curhelp(index)]} {[incr i -1] >= 0} {} {
201 <                        if {"$curhelp(category) $curhelp(topic)" ==
202 <                                        [lrange [string toupper [lindex \
200 <                                        $curhelp(index) $i]] 0 1]} {
201 <                                break
202 <                        }
203 <                }
204 <                if {$i < 0} {
200 >                if [info exists helpindex($curhelp(category),$curhelp(topic))] {
201 >                        seek $curhelp(fid) $helpindex($curhelp(category),$curhelp(topic))
202 >                } else {
203                          .helpwin.txt insert end "\nNo such help topic."
204                          .helpwin.txt configure -state disabled
205                          return ".$curhelp(category).$curhelp(topic) not found\
206                                          in $curhelp(file)"
207                  }
210                seek $curhelp(fid) [lindex [lindex $curhelp(index) $i] 2]
208          }
209          # Load help text into our window
210          set linepos 0
# Line 305 | Line 302 | proc helphist {op args} {              # access help history list
302   }
303  
304   proc helpsearch word {          # search for occurances of the given word
305 <        global curhelp
305 >        global curhelp helpindex
306          if {"$curhelp(search)" == {}} {
307                  set curhelp(msg) "No pattern."
308                  return 0
309          }
310          set nmatches 0
311 <        set cat [lindex [lindex $curhelp(index) 0] 0]
312 <        set top [lindex [lindex $curhelp(index) 0] 1]
311 >        set cat [lindex $curhelp(catlist) 0]
312 >        set top [lindex $helpindex([string toupper $cat]) 0]
313          set startpos [tell $curhelp(fid)]
314 <        seek $curhelp(fid) [lindex [lindex $curhelp(index) 0] 2]
314 >        seek $curhelp(fid) $helpindex([string toupper $cat,$top])
315          set foundmatch 0
316          while {[gets $curhelp(fid) li] >= 0} {
317                  if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines