home *** CD-ROM | disk | FTP | other *** search
- ## -*-Tcl-*-
- # ###################################################################
- # AlphaTcl - core Tcl engine
- #
- # FILE: "help.tcl"
- # created: 07/21/2000 {18:31:50 PM}
- # last update: 01/06/2001 {10:32:07 AM}
- #
- # The last 4 procs in this file are copyright (c) Pete Keleher
- # ###################################################################
- ##
-
- namespace eval help {}
-
- # Some Help files are available in multiple formats, such as html, pdf,
- # etc. This preference sets a default format to open, if available.
- newPref var helpMenuOptions 0 global "" \
- [list "Always offer options" \
- "Open html if available, then pdf" \
- "Open pdf if available, then html" \
- ] index
-
- lunion varPrefs(WWW) helpMenuOptions
-
- ##
- # -------------------------------------------------------------------------
- #
- # "alphaHelp" --
- #
- # Called from about box
- # -------------------------------------------------------------------------
- ##
-
- proc alphaHelp {} {
- global HOME alpha::platform
-
- set files [list "Alpha Manual" "Quick Start" "Readme"]
- foreach f $files {
- if {[file exists [file join $HOME Help $f]]} {
- helpMenu $f
- return
- }
- }
- # No help files present ...
- if {${alpha::platform} == "alpha"} {
- url::execute "http://www.alpha.olm.net/"
- } else {
- url::execute "http://www.santafe.edu/~vince/Alphatk.html"
- }
- }
-
- proc register {} {
- global HOME alpha::platform
-
- if {${alpha::platform} == "alpha"} {
- if {[file exists [file join $HOME Register]]} {
- launch -f [file join $HOME Register]
- } else {
- url::execute "http://www.alpha.olm.net/"
- }
- } else {
- alpha::finalStartup
- }
- }
-
- # ◊◊◊◊ Help Menu procedures ◊◊◊◊ #
-
- namespace eval help {}
-
- ##
- # -------------------------------------------------------------------------
- #
- # "help::buildMenu" --
- #
- # Note: All file extensions are removed from files in the Help folder when
- # building the Help menu, and no duplicates are inserted. If there are
- # two similarly named files with different extensions, the user can be
- # presented with a list pick dialog (in the proc: helpMenu below).
- #
- # Subdirectories --
- #
- # If tcl version is less than 8.0, subdirectories are simply added as menu
- # items. Selecting the item will present the user with a list-pick dialog
- # with the directory's contents, unless there is a .tcl file to be
- # evalutated first.
- #
- # 8.0 and greater, subdirectories are added as submenus, unless there is a
- # .tcl file present. In this case only the subdirectory's name is added
- # to the menu, and selecting it evaluates the .tcl file.
- # -------------------------------------------------------------------------
- ##
-
- proc help::buildMenu {} {
- global HOME alpha::platform
-
- if {![catch {glob -dir [file join $HOME Help] *} helpFiles]} {
- foreach f $helpFiles {
- lappend files [file rootname [file tail $f]]
- }
- } else {
- addHelpMenu "No Help files found"
- return
- }
- if {${alpha::platform} == "alpha"} {
- lappend men "Alpha Home Page"
- } else {
- lappend men "Alphatk Home Page"
- }
-
- # We automatically remove any which aren't actually there.
- lappend men \
- "Alpha's www FAQ" \
- "(-" \
- "Readme" "Readme Alphatk" "Quick Start" "Alpha Manual" "Packages" \
- "Mode Examples Help" "Bug Reports and Debugging" \
- "(-" \
- "Filesets Help" "FTP menu Help" "HTML Help" "LaTeX Help" \
- "(-" \
- "Extending Alpha" "Alpha Developers FAQ" "Alpha Commands" "Tcl Commands" \
- "Error Help" "AEGizmos" "TclAE Help" "Help Files Help" \
- "(-"
-
- if {${alpha::platform} == "alpha"} {
- lappend men "Changes - Alpha"
- } else {
- lappend men "Changes - Alphatk"
- }
-
- lappend men "Changes - AlphaTcl" "(-"
-
- # In this list, and for the remaining files in the Help folder, even if
- # there are multiple formats included the filename root is only added
- # once. If there are no files, we don't include them.
- foreach f $men {
- if {$f != "(-" && [lsearch $files $f] < 0} {
- set men [lremove $men $f]
- }
- }
- # Add the remaining filename root-tails.
- foreach f [lsort $files] {
- if {[lsearch $men $f] < 0} {
- lappend men $f
- }
- }
- regsub -all {\(-[ \t\r\n]+\(-} $men {\(-} men
- foreach f $men {
- if {[info tclversion] >= 8.0 && \
- [file isdirectory [file join $HOME Help $f]] && \
- ![file exists [file join $HOME Help ${f}.tcl]]} {
- # We only add sub-menus for tclversion 8.0 if a given
- # subdirectory doesn't have an associated .tcl file.
- set subfiles ""
- foreach sub [glob -nocomplain -dir [file join $HOME Help $f] *] {
- lappend subfiles [file root [file tail $sub]]
- }
- addHelpMenu [list Menu -n $f $subfiles]
- } else {
- addHelpMenu $f
- }
- }
- }
-
- proc help::MenuProc {menu item} {
- menu::generalProc help $item
- }
-
- proc helpMenu {args} {
- uplevel 1 help::openFile $args
- }
-
- ##
- # -------------------------------------------------------------------------
- #
- # "help::openFile" --
- #
- # Given the name delivered by the Help menu, find all files which contain
- # it (including the name itself, and any variations with file extensions).
- # If there are multiple files, or if the item selected is actually a
- # directory containing other files, offer the list to the user.
- #
- # Thus there can be multiple versions of "LaTeX Help" (for example), such
- # as "LaTeX Help", "LaTeX Help.html", "LaTeX Help.pdf", "LaTeX Help",
- # which will be dealt with by help::openDirect.
- #
- # If there is a "<something> Help.tcl" file, as in "LaTeX Help.tcl", then
- # that file is sourced immediately. It's up to the script to decide if
- # more options will be presented.
- # -------------------------------------------------------------------------
- ##
-
- proc help::openFile {args} {
- global HOME alpha::platform helpMenuOptions
-
- # Set the filename delivered by the Help menu.
- set filename [eval [list file join $HOME Help] $args]
- if {[file exists ${filename}.tcl]} {
- # There's a .tcl script to evaluate. It is up to the script to
- # decide if more options will be presented.
- help::openDirect ${filename}.tcl
- return
- } elseif {[file tail $filename] == "No Help files found"} {
- # The list was built without any files.
- if {[askyesno "No help files were found -- perhaps you need to \
- re-install them. Would you like to open Alpha's home page?"] != "no"} {
- if {${alpha::platform} == "alpha"} {
- url::execute "http://www.alpha.olm.net/"
- } else {
- url::execute "http://www.santafe.edu/~vince/Alphatk.html" }
- } else {
- error "No Help files found in the top level of Alpha's hierarchy."
- }
- }
- # Find out what file options we have.
- set fileDir [file dirname $filename]
- if {[file isdirectory $filename]} {
- # This item is actually a subdirectory.
- set fileDir $filename
- set files [glob -nocomplain -dir $filename *]
- } elseif {[catch {glob -path "${filename}." *} files]} {
- # There are no files with this name plus an extension.
- set files ""
- }
- if {(![llength $files] || !$helpMenuOptions) && [file isfile $filename]} {
- # The filename exists without an extension, so we add that too.
- lappend files $filename
- }
- if {![llength $files]} {
- # "filename" shouldn't have even been in the menu ...
- message "Sorry, no \"$filename\" files were found."
- error "No \"$filename\" files were found."
- }
- # Now that the list of potential files has been set, check some of the
- # "help menu" preferences to see if we have some default action, or if
- # we should adjust the list.
- if {$helpMenuOptions == 1} {
- # User would prefer a pdf file, then a html file.
- if {[file exists ${filename}.pdf]} {
- set helpFile ${filename}.pdf
- } elseif {[file exists ${filename}.html]} {
- set helpFile ${filename}.html
- }
- } elseif {$helpMenuOptions == 2} {
- # User would prefer a html file, then a pdf file.
- if {[file exists ${filename}.html]} {
- set helpFile ${filename}.html
- } elseif {[file exists ${filename}.pdf]} {
- set helpFile ${filename}.pdf
- }
- }
- if {![info exists helpFile]} {
- # No file has been set yet.
- if {[llength $files] == 1} {
- # Only one file found.
- set helpFile [lindex $files 0]
- } else {
- # There is more than one file, with different extensions.
- foreach f $files {
- lappend fileTails [file tail $f]
- }
- lappend fileTails "(Set WWW preferences to avoid this dialog …)"
- set helpFile [listpick -p "\"[file tail $filename]\" options : " $fileTails]
- if {$helpFile == "(Set WWW preferences to avoid this dialog …)"} {
- dialog::preferences preferences "WWW"
- helpMenu $args
- return
- }
- set helpFile [file join $fileDir $helpFile]
- # In case $helpFile is itself a directory ... This will also
- # help make sure that the help menu item can work even if a
- # .tcl file has been deleted.
- while {[file isdirectory $helpFile]} {
- set files [glob -nocomplain -dir $helpFile *]
- set fileTails ""
- foreach f $files {
- lappend fileTails [file tail $f]
- }
- set fileDir $helpFile
- set helpFile [listpick -p \
- "\"[file tail $helpFile]\" options :" \
- [lsort $fileTails]]
- set helpFile [file join $fileDir $helpFile]
- }
- }
- }
- help::openDirect $helpFile
- }
-
- ##
- # ----------------------------------------------------------------------
- #
- # "help::mimicHelpMenu" --
- #
- # This proc can be used in the Alpha Developer Menu's "Help File Marking"
- # menu, or called by other code. Assume that this is for the current
- # open window unless called from a shell prompt.
- #
- # "help::mimicHelpMenu -choose" will offer a list-pick dialog to select
- # files for pre-marking.
- #
- # "help::mimicHelpMenu -all" will pre-mark all Help files, useful for
- # public releases of Alpha (not Alphatk).
- #
- # Both options will only select valid (i.e. Text mode) files in the top
- # level of the Help folder.
- # ----------------------------------------------------------------------
- ##
-
- proc help::mimicHelpMenu {{files ""}} {
-
- global HOME alpha::platform
-
- set fileList ""
- # Should we select of list of files to mark/hyper ...
- if {$files == "-choose" || $files == "-all"} {
- # Create the list of all valid help files (those in Text mode).
- message "Creating the list of valid Help files for marking/hyperizing …"
- foreach f [glob -dir [file join $HOME Help] *] {
- if {[file isfile $f] && [win::FindMode $f] == "Text"} {
- lappend helpFiles $f
- }
- }
- if {$files == "-choose"} {
- # Offer a list-pick of Help files to mark/hyper.
- foreach f $helpFiles {
- if {[file isfile $f] && [win::FindMode $f] == "Text"} {
- lappend helpFileTails [file tail $f]
- }
- }
- set helpTailsList [listpick -l \
- -p "Choose some Help files to pre-mark" $helpFileTails]
- foreach f $helpTailsList {
- lappend fileList [file join $HOME Help $f]
- }
- } elseif {${alpha::platform} != "alpha"} {
- alertnote "Pre-marking/hyperizing help files is only useful\
- for the Macintosh platform."
- error "\"help::mimicHelpMenu -all\" is only useful on the Macintosh."
- } else {
- # Select all valid help files to mark.
- set fileList $helpFiles
- }
- }
- # ... or given a single file argument "f", which is surrounded either
- # by quotes or brackets, assume that the file is in the Help folder
- # unless the entire path is given ...
- if {$files != "" && $fileList == ""} {
- set f1 [list $files]
- set f2 [file join $HOME Help $files]
- if {[file isfile $f1]} {
- lappend fileList $f1
- } elseif {[file isfile $f2]} {
- lappend fileList $f2
- }
- }
- # ... or given no arguments, use the current window.
- if {$files == ""} {
- set fileList [list [win::Current]]
- }
- # Do we have any files to mark/hyper?
- if {![llength $fileList]} {
- message "No valid files were selected."
- error "No valid files were selected."
- }
- # Now we actually mark/hyper the file.
- foreach f $fileList {
- # We already know that all files in "f2" exist, are complete paths.
- help::removeCHMCleanly $f
- help::openDirect [win::Current]
- setWinInfo dirty 0
- setWinInfo read-only 0
- if {$files == "-all"} {
- # If only marking files for public release, close them.
- shrinkFull
- menu::fileProc "File" "close"
- }
- }
- }
-
- proc help::preMarkAllHelpFiles {} {
- if {[askyesno "Do you really want to mark and hyper all help files?\
- This could take a little while …"] != "no"} {
- help::mimicHelpMenu -all
- }
- }
-
- # ◊◊◊◊ Open File procedures ◊◊◊◊ #
-
- ##
- # -------------------------------------------------------------------------
- #
- # "help::openDirect" --
- #
- # Called from the Help menu to evaluate (.tcl), send (.html), or just
- # open/mark/hyper (no extension) a file . Other formats opened by OS.
- # ------------------------------------------------------------------------
- ##
-
- proc help::openDirect {filename} {
- if {![file exists $filename]} {
- global HOME
- set filename [file join $HOME Help $filename]
- }
- if {[file isfile $filename]} {
- switch -- [file extension $filename] {
- ".tcl" {
- uplevel \#0 [list source $filename]
- }
- ".html" {
- htmlView $filename
- }
- "" {
- edit -r -c -tabsize 4 $filename
- global mode
- if {$mode == "Chng"} {
- Chng::MarkFile
- help::hyperiseUrls
- }
- if {$mode == "Text" && ![llength [getColors]]} {
- catch {
- message "Please wait: Colouring and marking the help file"
- help::hyperiseEmailAddresses
- help::hyperiseUrls
- set commandFiles [list \
- "Diff Help" "Error Help" "Perl Commands" \
- "Regular Expressions" "Tcl Commands" \
- ]
- set f [win::CurrentTail]
- if {$f == "Alpha Commands"} {
- help::markAlphaCommands
- } elseif {[lsearch $commandFiles $f] != "-1"} {
- help::markTclCommands
- } else {
- help::colourHeadingsEtc
- }
- message ""
- file::saveResourceChanges $filename
- }
- }
- }
- default {
- file::openInDefault $filename
- }
- }
- } else {
- file::openAny $filename
- }
- }
-
- ##
- # -------------------------------------------------------------------------
- #
- # "help::openGeneral" --
- #
- # Called by embedded hyperlinks; look first for "package" help, and
- # otherwise try to open the named help file (as if from Help menu.)
- # ------------------------------------------------------------------------
- ##
- proc help::openGeneral {name} {
- global HOME
- regsub -nocase { Help} $name {} package
- if {[catch {package::helpFile $package}]} {
- help::openFile $name
- }
- }
-
- ##
- # -------------------------------------------------------------------------
- #
- # "help::openExample" --
- #
- # Called by embedded hyperlinks.
- #
- # Example files must be of the form "<something>-Example.sfx", with the
- # suffix optional. If the hyperlink looks like "<something> Example.sfx",
- # it will open in a shell window, and inserts some explanatory text at the
- # beginning. If there is a completions tutorial available for the mode,
- # that will be noted as well.
- #
- # Exceptions (which are evaluated first):
- #
- # -- Hyperlinks such as "<something>-Example.sfx" (the actual file name,
- # with the dash) open the actual example file, read-only.
- #
- # -- If a package includes not only an example file, but wants to do
- # something special with it, then it should install two different files,
- # both a "<something>-Example.sfx" AND a "<something>-Example.sfx.tcl"
- # file, and make the hyperlink with "<something> Example.sfx" .
- #
- # The presence of a "<something>-Example.sfx.tcl" file creates a special
- # case. The hyperlink "Calculator Example", for example, evaluates the
- # file "Calculator-Example.tcl", which will then open a calculator window,
- # etc. ("Tcl Example.tcl" will simply open as an example without being
- # sourced, because there is no "Tcl-Example.tcl.tcl" file.)
- #
- # ------------------------------------------------------------------------
- ##
-
- proc help::openExample {name} {
- global HOME
-
- regsub -all { } $name {-} name2
- set f [file join $HOME "Mode Examples" $name]
- set f2 [file join $HOME "Mode Examples" $name2]
-
- if {$name == $name2 && [file exists $f]} {
- # Open as a read-only file
- edit -r -c $f
- return
- } elseif {[file exists ${f2}.tcl]} {
- # A special case -- evaluate the ${f2}.tcl file.
- uplevel \#0 [list source ${f2}.tcl]
- return
- } elseif {[file exists ${f}.tcl]} {
- # We'll also check to see if the file was erroneously named without
- # the dash, as in "<something> example.tcl" .
- uplevel \#0 [list source ${f}.tcl]
- return
- } elseif {![file exists $f2]} {
- # Special cases done, but the file defined by "f" doesn't exist.
- beep
- message "Sorry, \"$name2\" is not in the Mode Examples folder"
- return
- }
- # File exists, and it's not a special case, so open it in a shell window.
- set m [win::FindMode $f2]
- # Does Alpha know what mode this is? If not, send an alertnote.
- if {$m == "Text"} {
- alertnote "Alpha doesn't recognize the mode for this example,\
- and will open it in as plain text."
- }
- new -n "* $m Mode Example *" -m $m -text [file::readAll $f2] -shell 1
- goto [minPos]
- set t "\r $m mode example -- Modify as much as you like ! \r\r"
- append t " None of the changes you make will affect the actual file. If you close \r"
- append t " the window and then click on the hyperlink again, you will start with the \r"
- append t " same example as before. This also means that you cannot send this window \r"
- append t " to other applications -- technically, it doesn't exist as a file. \r\r"
- append t " Type \"control-Help\" to open any available help for $m mode. \r\r"
- # Find out if there's a tutorial available for this mode.
- set f3 [file join ${HOME} Tcl Completions "[modeALike] Tutorial"]
- if {[llength [glob -nocomplain -path $f3 *]] == 1} {
- append t " $m mode also has a Completions Tutorial in the Config --> Mode Prefs menu.\r\r"
- }
- insertText $t
- goto [minPos]
- if {$m == "Text"} {
- help::hyperiseEmailAddresses
- help::hyperiseUrls
- }
- # Now try to mark the file.
- markFile
- }
-
- ##
- # -------------------------------------------------------------------------
- #
- # "help::openHyper" --
- #
- # Called by embedded hyperlinks; we look through an installation
- # directory (and subdirs) if it is known, then the prefs directory, then
- # all of the auto_path. If it is a tutorial shell, find the proper mode
- # and open it in a shell window. Otherwise, if the file is of type TEXT
- # we open it as read-only, else we ask the finder to open it.
- # -------------------------------------------------------------------------
- ##
-
- proc help::openHyper {name} {
- global PREFS tclExtensionsFolder auto_path file::separator
- set currD [list [file dirname [win::Current]]]
- set dirs [glob -types d -dir $currD -nocomplain -- *]
- foreach d $dirs {
- lappend currD [string trimright $d ${file::separator}]
- }
- lappend currD $PREFS
- if {[info exists tclExtensionsFolder]} {lappend currD $tclExtensionsFolder}
- foreach d [concat $currD $auto_path] {
- if {[regsub -nocase {Prefs.tcl} $name {} m]} {
- if {$m != ""} {
- # Edit a <mode>Prefs.tcl file, prompting to create if necessary.
- mode::editPrefsFile $m
- } else {
- # Edit a prefs.tcl file, creating one if necessary.
- prefs::tclEdit
- }
- return
- }
- set f [file join $d $name]
- if {[file exists $f]} {
- if {[regexp {Tutorial} $name]} {
- # This is a tutorial, so open it in a shell window
- mode::completionsTutorial [win::FindMode $f]
- } elseif {[getFileType $f] == {TEXT}} {
- # Type is Text, so open as read-only
- edit -r -c $f
- } else {
- # Unknown type, so prompt user
- file::openAny $f
- }
- return
- }
- }
- beep
- message "Sorry, couldn't find $name"
- }
-
- # ◊◊◊◊ File Marking / Hyperizing ◊◊◊◊ #
-
- ##
- # ----------------------------------------------------------------------
- #
- # "help::hyperiseUrls" --
- # "help::hyperiseEmailAddresses" --
- #
- # This attaches hypertext links to all '<http:... >' or '<mailto...>'
- # strings in a document. This procedure works best on files in Text
- # mode; in other modes the colouring schemes can make the links invisible
- # (although they still function).
- #
- # ----------------------------------------------------------------------
- ##
-
- proc help::hyperiseUrls {} {
- win::searchAndHyperise {<((http|news|mailto|ftp):[^ ]*)>} {url::execute "\1"} 1
- }
-
- proc help::hyperiseEmailAddresses {} {
- win::searchAndHyperise \
- {<([-_a-zA-Z0-9.]+@([-_a-zA-Z0-9.]+))>} \
- {url::execute "mailto:\1"} 1
- }
-
- # Note: some regexps in this proc are full of extra (()|()) stuff which can
- # be removed.
- proc help::colourHeadingsEtc {{markFile 1}} {
-
- if {$markFile} {
- catch {help::markAlphaManual}
- catch {help::colorManualMarks}
- }
- # Search for "<something>.tcl" and attach appropriate lookup.
- # Search for "<something >Tutorial<.sfx>" and attach appropriate lookup.
- win::searchAndHyperise {"([-a-zA-Z_+1-9 ]*\.tcl|Text Tutorial|[-a-zA-Z0-9_+ ]+Tutorial(([.a-zA-Z0-9_ ]+[.a-zA-Z0-9_])?.\w+))"} \
- {help::openHyper "\1"} 1 3 +1 -1
- # Search for "package: <something>" and attach appropriate lookup.
- win::searchAndHyperise {package: ([-a-zA-Z0-9+]*[-a-zA-Z0-9+])} \
- {help::openGeneral "\1"} 1 4 +9
- # search for "<something>Example" and attach appropriate lookup.
- win::searchAndHyperise {"([-a-zA-Z_+0-9 ]*Example(\.[a-zA-Z0-9_]+)?)"} \
- {help::openExample "\1"} 1 3 +1 -1
- # Search for "<<something>>" and embed as hypertext.
- # (Can only handle ] at end of string, not within ...)
- win::searchAndHyperise {<<([^>\r\n]+)>>} {\1} 1 4 +2 -2
- # Search for "proc: <something>" and attach appropriate lookup.
- win::searchAndHyperise {proc: ([-a-zA-Z:\+\.\_]+\w+)} \
- {Tcl::DblClickHelper "\1" ; setWinInfo read-only 1} 1 4 +6
- # Search for "command: <something>" and attach appropriate lookup.
- win::searchAndHyperise {command: ([-\w+:\+\.\_]+(\w+))} \
- {Tcl::DblClickHelper "\1" ; setWinInfo read-only 1} 1 4 +9
-
- # Help file hyperlinks --
- # Don't make these lists too long, or there will be memory corruption.
- # search for "<something>Help" etc and attach appropriate lookup.
- win::searchAndHyperise {\"([-a-zA-Z_0-9+ ]+(Help|Commands))\"} \
- {help::openGeneral "\1"} 1 3 +1 -1
- # search for specific Help files and attach appropriate lookup.
- win::searchAndHyperise {\"(Alpha Manual|Readme|Extending Alpha|Quick Start|Bug Reports and Debugging)\"} \
- {help::openGeneral "\1"} 1 3 +1 -1
- win::searchAndHyperise {\"(Changes|Changes - Alpha|Changes - AlphaTcl|Changes - Alphatk|Alpha Developers FAQ)\"} \
- {help::openGeneral "\1"} 1 3 +1 -1
- # search for more specific Help files and attach appropriate lookup.
- # Note -- the more win::searchAndHyperise, the slower the marking.
- # Changing Help file filenames to "<something> Help" is a better solution.
- win::searchAndHyperise {"(Default Key Bindings|Internet Config|Packages|Regular Expressions)"} \
- {help::openGeneral "\1"} 1 3 +1 -1
- win::searchAndHyperise {"(AEGizmos|CodeWarrior|MacPerl Specifics|Registering|Shells)"} \
- {help::openGeneral "\1"} 1 3 +1 -1
- win::searchAndHyperise {\"(Symantec|Tcl Resources)\"} \
- {help::openGeneral "\1"} 1 3 +1 -1
- # etc. More could be added.
-
- # Highlight IMPORTANT bits
- win::searchAndHyperise {IMPORTANT:} {} 0 5
- # Highlight "<something>-><something>" menu directions
- win::searchAndHyperise {"([-a-zA-Z_ ]+-> ?)+[a-zA-Z_ ]+(…|...)?"} {} 1 5 +1 -1
- # Highlight '<something>-><something>' menu directions
- win::searchAndHyperise {'([-a-zA-Z_ ]+-> ?)+[a-zA-Z_ ]+(…|...)?'} \
- {} 1 5 +1 -1
- # make code inserts blue
- set bluestr {^[ \t]*[\r\n]\t[^•" \t\r\n][^\n\r]*[\r\n](\t([ \t]*[\r\n]|[ \t]*[^ \t\r\n]+[^\n\r]*[\r\n]))*[ \t]*[\r\n]}
- win::searchAndHyperise $bluestr {} 1 1
- win::searchAndHyperise {CLICK[ A-Z]* INSTALL} "install::installThisPackage" 1 3
- if {![catch {set inds [search -f 1 -r 1 {Jump to recent changes} [minPos]]}]} {
- set from [lindex $inds 0]
- set to [lindex $inds 1]
- text::color $from $to 3
- text::hyper $from $to {gotoMark " Recent Changes:"}
- }
- goto [minPos]
- }
-
- ##
- # ----------------------------------------------------------------------
- #
- # "help::removeAllColoursAndHypers" --
- # "help::removeCHMCleanly" --
- #
- # Remove all colors and hypers from the current window. Removing them
- # "cleanly" also removes marks, but will not change the last save date
- # contained in the resource fork. "help::removeCHMCleanly" is also used
- # by "help::mimicHelpMenu".
- # ----------------------------------------------------------------------
- ##
-
- proc help::removeAllColoursAndHypers {} {
- # get rid of the old stuff
- catch { removeColorEscapes }
- refresh
- }
-
- proc help::removeCHMCleanly {{filePath ""}} {
-
- global HOME win::Active
-
- # This proc can be used for open windows, or called by other code.
- if {$filePath != ""} {
- file::openQuietly $filePath
- } elseif {[llength [set win::Active]] < 1} {
- findFile [file join $HOME Help ""]
- }
- # Altered windows can not be saved "cleanly"
- if {![catch {getWinInfo arr}] && $arr(dirty)} {
- beep ; message "File must first be saved."
- error "File must first be saved."
- }
- setWinInfo read-only 0
- removeAllMarks
- help::removeAllColoursAndHypers
- setWinInfo dirty 0
- }
-
- ##
- # ----------------------------------------------------------------------
- #
- # "help::markTclCommands" --
- #
- # An alternative marking scheme for help files which mainly contain lists
- # of commands. See "Tcl Commands" or "Error Help" for examples.
- # ----------------------------------------------------------------------
- ##
-
- proc help::markTclCommands {} {
- global mode
-
- # Change mode to Tcl to use word break preference,
- # in case the commands use :: .
- set m $mode
- changeMode Tcl
- # Mark the Command file
- removeAllMarks
- set pos [minPos]
- while {![catch {search -f 1 -r 1 -i 0 "^\[\t \]*NAME" $pos} inds]} {
- set pos1 [lindex $inds 0]
- goto [lindex $inds 1]
- hiliteWord
- text::color [getPos] [selEnd] 1
- setNamedMark [getSelect] $pos1 $pos1 $pos1
- set pos [nextLineStart $pos1]
- }
- # Search and color red lines with all CAP words.
- set pos [minPos]
- while {![catch {search -f 1 -r 1 -i 0 {^[A-Z,\t ]+$} $pos} inds]} {
- set from [lindex $inds 0]
- set to [lindex $inds 1]
- text::color $from $to 5
- set pos [nextLineStart $from]
- }
- # Color, underline the title (first alphanumeric line in file), and
- # then color / hyper any extras using help::colourHeadingsEtc.
- goto [minPos]
- hiliteWord
- endLineSelect
- text::color [getPos] [selEnd] 5
- text::color [getPos] [selEnd] 15
- help::colourHeadingsEtc 0
- # Change mode back to original
- changeMode $m
- }
-
- # This proc is obsolete I think - Vince.
- proc help::markReadme {} {
- removeAllMarks
- help::removeAllColoursAndHypers
- win::multiSearchAndHyperise "Home Page" \
- {url::execute http://alpha.olm.net/} \
- "Quick Start" {edit -r [file join ${HOME} Help "Quick Start"]} \
- "Bug Reports And Debugging" \
- {edit -r [file join ${HOME} Help "Bug Reports And Debugging"]} \
- "Manual" {edit -r [file join ${HOME} Help "Alpha Manual"]} \
- "Click here to update Alpha's list of remote packages via the internet" \
- {package::queryWebForList} \
- "Config->Preferences->International" \
- {dialog::preferences Preferences International}
-
- win::searchAndHyperise "[\r\n]Help" {alphaHelp} 1 3 1
- win::searchAndHyperise "'Changes'" {edit -r [file join ${HOME} Help "Changes - Alpha"]} 0 3 1 -1
- win::searchAndHyperise {<get ([^>]+)>} {remote::get \1} 1
- win::searchAndHyperise {[\w ']+ \-\-\-} { } 1 5 0 -4
- help::hyperiseUrls
- help::hyperiseEmailAddresses
-
- }
-
- # ◊◊◊◊ Pete's manual-marking routines ◊◊◊◊ #
-
- proc help::markAlphaManual {} {
- set pos [minPos]
- set labels ""
- while {[string length [set inds [search -f 1 -r 1 {^\t \t} $pos]]]} {
- set pos1 [lindex $inds 1]
- set label [getText $pos1 [pos::math [nextLineStart $pos1] - 1]]
- regsub -all "\t" $label " " label
- set pos2 [lineStart $pos1]
- if {$label == ""} {set label "-"}
- while {[lsearch -exact $labels $label] != -1} { append label " " }
- setNamedMark $label $pos2 $pos2 $pos2
- lappend labels $label
- set pos [nextLineStart $pos1]
- }
- }
-
- proc help::colorManualMarks {} {
- goto [minPos]
- hiliteWord
- endLineSelect
- set from [getPos]
- set to [selEnd]
- text::color $from $to 5
- text::color $from $to 15
-
- foreach mk [getNamedMarks] {
- set name [lindex $mk 0]
- set disp [lindex $mk 2]
- set pos [lindex $mk 3]
- set end [lindex $mk 4]
-
- goto $disp
- hiliteWord
- endLineSelect
- set from [getPos]
- set to [selEnd]
- text::color $from $to 5
- text::color $from $to 15
- }
- }
-
- proc help::markAlphaCommands {} {
- global HOME alpha::platform
- if {[set alpha::platform] == "alpha"} {
- setWinInfo read-only 0
- }
- help::removeAllColoursAndHypers
- removeAllMarks
- changeMode Tcl
- set pos [minPos]
- while {![catch {search -f 1 -r 1 {^• } $pos} inds]} {
- set pos1 [lindex $inds 1]
- goto $pos1
- hiliteWord
- set label [getSelect]
- set from [getPos]
- set to [selEnd]
- setNamedMark $label $pos1 $from $to
- text::color $from $to 1
- set pos [nextLineStart $pos1]
- }
- select [minPos] [nextLineStart [nextLineStart [nextLineStart [minPos]]]]
- redWord
- changeMode Text
- goto [minPos]
- if {[set alpha::platform] == "alpha"} {
- save
- }
- }
-
- proc help::markAlphaChanges {} {
- set pos [minPos]
- while {[string length [set inds [search -f 1 -r 1 {^= } $pos]]]} {
- set pos1 [lindex $inds 1]
- goto $pos1
- endLineSelect
- redWord
- set pos [nextLineStart $pos1]
- }
- }
-