--- ray/src/util/gethelp3.6.tcl 1994/10/28 19:12:02 2.4 +++ ray/src/util/gethelp3.6.tcl 2003/02/22 02:07:30 2.12 @@ -1,4 +1,4 @@ -# SCCSid "$SunId$ LBL" +# RCSid: $Id: gethelp3.6.tcl,v 2.12 2003/02/22 02:07:30 greg Exp $ # # Get help from a file, formatted like so: # @@ -24,10 +24,10 @@ set curhelp(file) {} proc gethelp {helpfile category topic} { # Open help window global curhelp helpfontwidth if {! [winfo exists .helpwin]} { # Set up window - toplevel .helpwin + toplevel .helpwin -cursor top_left_arrow wm minsize .helpwin 500 400 wm iconbitmap .helpwin question - frame .helpwin.but -geometry 150x400 + frame .helpwin.but -width 150 -height 400 pack .helpwin.but -side right -fill none -expand no label .helpwin.but.lab -textvariable curhelp(title) place .helpwin.but.lab -relx .1667 -rely 0 @@ -122,26 +122,39 @@ proc helpopen fname { # open the named help file wm title .helpwin $fname set curhelp(title) "[string toupper\ [file rootname [file tail $fname]]] HELP" + set ifile [file rootname $fname].ndx wm iconname .helpwin [string tolower $curhelp(title)] .helpwin.txt configure -state normal .helpwin.txt delete 1.0 end .helpwin.txt insert end "Loading $fname..." update set curhelp(fid) [open $fname r] - set curhelp(catlist) {} - while {[gets $curhelp(fid) li] >= 0} { - if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \ - $li dummy cat top] { - lappend helpindex([string toupper $cat]) $top - set helpindex([string toupper $cat,$top]) \ - [tell $curhelp(fid)] - if {[lsearch -exact $curhelp(catlist) $cat] < 0} { - lappend curhelp(catlist) $cat + if {! [file isfile $ifile] || + [file mtime $fname] > [file mtime $ifile]} { + set helpindex(catlist) {} + while {[gets $curhelp(fid) li] >= 0} { + if [regexp -nocase {^\.([A-Z][A-Z0-9]*)\.([A-Z][A-Z0-9]*)$} \ + $li dummy cat top] { + lappend helpindex([string toupper $cat]) $top + set helpindex([string toupper $cat,$top]) \ + [tell $curhelp(fid)] + if {[lsearch -exact $helpindex(catlist) $cat] < 0} { + lappend helpindex(catlist) $cat + } } } + if {! [catch {set fi [open $ifile w]}]} { + puts $fi "# This is an automatically created index\ + file -- DO NOT EDIT!" + writevars $fi helpindex + close $fi + catch {exec chmod 666 $ifile} + } + } else { + source $ifile } .helpwin.but.catb.m delete 0 last - foreach cat $curhelp(catlist) { + foreach cat $helpindex(catlist) { .helpwin.but.catb.m add command -label $cat \ -command "helphist new $cat intro" } @@ -237,6 +250,7 @@ proc helpupdate {} { # update help text window set curhelp(next) "$cat $top" .helpwin.but.next configure -state normal } else { + set curhelp(next) {} .helpwin.but.next configure -state disabled } .helpwin.txt configure -state disabled @@ -297,7 +311,7 @@ proc helpsearch word { # search for occurances of the return 0 } set nmatches 0 - set cat [lindex $curhelp(catlist) 0] + set cat [lindex $helpindex(catlist) 0] set top [lindex $helpindex([string toupper $cat]) 0] set startpos [tell $curhelp(fid)] seek $curhelp(fid) $helpindex([string toupper $cat,$top])