From 61121245f1756468f9e93412d9869c5691fb5a51 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes Date: Mon, 21 Jan 2013 04:37:30 +0000 Subject: Added link to the glossary svn path=/trunk/scripts/guiplugins/search-plugin/; revision=16927 --- search-plugin.tcl | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/search-plugin.tcl b/search-plugin.tcl index 97b255b..9889d6e 100644 --- a/search-plugin.tcl +++ b/search-plugin.tcl @@ -27,6 +27,7 @@ namespace eval ::dialog_helpbrowser2:: { variable navbar {} variable genres variable cancelled + variable terms_to_match } ################## help browser and support functions ######################### @@ -498,14 +499,32 @@ proc ::dialog_helpbrowser2::do_search { } { variable filelist {} variable i 0 variable cancelled 0 + variable terms_to_match foreach genre $genres { lappend count 0 } - - # Get rid of pesky leading/trailing spaces... + # Get rid of any leading/trailing spaces... set formatted_searchtext [string trim $searchtext] # ...and double spaces between terms regsub -all {\s+} $formatted_searchtext { } formatted_searchtext + if {$::dialog_helpbrowser2::matchwords == 1} { + # let's design our own word boundaries since tildes often + # end Pure Data words. + # custom left boundary isn't necessary, but I included it + # anyway just in case we need it later on. + set lb {(?:^|[^[:alnum:]_])} + set rb {(?![[:alnum:]_~])} + set tmplist {} + foreach term $formatted_searchtext { + lappend tmplist [join [list $lb $term $rb] ""] + } + set formatted_searchtext $tmplist + } + set terms_to_match 1 + if { $::dialog_helpbrowser2::matchall == 1 } { + set terms_to_match [llength $formatted_searchtext] + } + set dirs [concat [file join $::sys_libdir doc] $::sys_searchpath $::sys_staticpath] foreach basedir $dirs { # Fix the directory name, this ensures the directory name is in the @@ -616,19 +635,9 @@ proc ::dialog_helpbrowser2::directory_sort { list } { proc ::dialog_helpbrowser2::searchfile {searchtext file_contents widget filename basedir} { variable count variable genres + variable terms_to_match set match 0 - set terms_to_match 1 - if { $::dialog_helpbrowser2::matchall == 1 } { - set terms_to_match [llength $searchtext] - } - # let's design our own word boundaries since tildes often end Pure Data words. - # homemade left boundary isn't necessary, but makes it easy to change later - set lb {(?:^|[^[:alnum:]_])} - set rb {(?![[:alnum:]_~])} foreach term $searchtext { - if {$::dialog_helpbrowser2::matchwords == 1} { - set term [join [list $lb $term $rb] ""] - } if {[regexp -nocase -- $term $filename] || [regexp -nocase -- $term [join $file_contents]]} { incr match @@ -759,6 +768,10 @@ proc ::dialog_helpbrowser2::intro { t } { $t insert end "\n" $t insert end [_ "External Pd libraries"] "link libdirs intro_libdirs" $t insert end "\n" + $t insert end [_ "Pure Data Glossary"] "link homepage_file" + $t insert end [file join $::sys_libdir doc 5.reference] basedir + $t insert end glossary.pd filename + $t insert end "\n" $t insert end [_ "Browse Introductory Topics"] homepage_title $t insert end "\n" set intro_docs [list \ -- cgit v1.2.1