From 5a5bff1d821c2df9e6ac3f60566660b3c4e40136 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes Date: Fri, 30 Nov 2012 07:51:54 +0000 Subject: fixed widget color discrepancy on OSX svn path=/trunk/scripts/guiplugins/search-plugin/; revision=16620 --- README.txt | 4 +- search-plugin.tcl | 681 ++++++++++++++++++++++++++++++------------------------ 2 files changed, 378 insertions(+), 307 deletions(-) diff --git a/README.txt b/README.txt index e168a99..269231d 100644 --- a/README.txt +++ b/README.txt @@ -14,8 +14,8 @@ A lot of care has been taken so that the average user can get by without directly using regular expressions at all. For example, typing "melod(y|ies)" in the search bar is equivalent to typing "melody melodies" and unchecking the box for "Match all terms". Additionally, a complex regular expression -like the one above can be triggered by clicking one of various links under -the heading "Keywords Search" on the homepage of the search window. +like the keywords example above may be triggered by clicking one of various +links under the heading "Keywords Search" on the homepage of the search window. You can find out about the Tcl regexp syntax here for advanced searches: http://tcl.tk/man/tcl8.5/TclCmd/re_syntax.htm diff --git a/search-plugin.tcl b/search-plugin.tcl index 1cf1096..23c28c0 100644 --- a/search-plugin.tcl +++ b/search-plugin.tcl @@ -1,15 +1,20 @@ -# plugin to allow searching all the documentation using a regexp -# check the Help menu for the Search item to use it +# browse docs or search all the documentation using a regexp +# check the Help menu for the Browser item to use it -# Bugs: -# tiny text in combobox dropdown menu on Windows -# can't interrupt long searches on Windows +# todo: cancel button +# todo: make libdir listing check for duplicates +# todo: hook into the dialog_bindings +# TODO remove the doc_ prefix on procs where its not needed +# TODO enter and up/down/left/right arrow key bindings for nav package require Tk 8.5 package require pd_bindings package require pd_menucommands -namespace eval ::dialog_search:: { +namespace eval ::dialog_helpbrowser2:: { + + variable doctypes "*.{pd,pat,mxb,mxt,help,txt,htm,html,pdf}" + variable searchfont [list {DejaVu Sans}] variable searchtext {} variable formatted_searchtext {} @@ -20,20 +25,252 @@ namespace eval ::dialog_search:: { variable filelist {} variable progress {} variable navbar {} + variable genres + variable cancelled +} + +################## help browser and support functions ######################### +proc ::dialog_helpbrowser2::open_helpbrowser {mytoplevel} { + if {[winfo exists $mytoplevel]} { + wm deiconify $mytoplevel + raise $mytoplevel + } else { + create_dialog $mytoplevel + } +} + +proc ::dialog_helpbrowser2::create_dialog {mytoplevel} { + variable searchfont + variable selected_file variable genres [list [_ "All documents"] \ - [_ "Object Help Patches"] \ - [_ "All About Pd"] \ - [_ "Tutorials"] \ - [_ "Manual"] \ - [_ "Uncategorized"] \ + [_ "Object Help Patches"] \ + [_ "All About Pd"] \ + [_ "Tutorials"] \ + [_ "Manual"] \ + [_ "Uncategorized"] \ ] -} + variable count + foreach genre $genres { + lappend count 0 + } + toplevel $mytoplevel -class DialogWindow + wm title $mytoplevel [_ "Search and Browse Documentation"] + wm geometry $mytoplevel 670x550+0+30 + wm minsize $mytoplevel 230 360 + # tweak: get rid of arrow so the combobox looks like a simple entry widget + ttk::style configure Entry.TCombobox -arrowsize 0 + ttk::style configure Genre.TCombobox + ttk::style configure Search.TButton -font menufont + ttk::style configure Search.TCheckbutton -font menufont + # widgets + # for some reason ttk widgets didn't inherit menufont, and this causes tiny + # fonts on Windows-- so let's hack! + foreach widget {f.genrebox advancedlabel } { + option add *[string trim "$mytoplevel.$widget" .]*font menufont + } + foreach combobox {searchtextentry f.genrebox} { + option add *[string trim "$mytoplevel.$combobox" .]*Listbox.font menufont + } + ttk::frame $mytoplevel.f -padding 3 + ttk::combobox $mytoplevel.f.searchtextentry -textvar ::dialog_helpbrowser2::searchtext \ + -font "$searchfont 12" -style "Entry.TCombobox" -cursor "xterm" + ttk::button $mytoplevel.f.searchbutton -text [_ "Search"] -takefocus 0 \ + -command ::dialog_helpbrowser2::search -style Search.TButton + ttk::combobox $mytoplevel.f.genrebox -values $genres -state readonly \ + -style "Genre.TCombobox" + $mytoplevel.f.genrebox current 0 + ttk::checkbutton $mytoplevel.f.matchall_check -text [_ "Match all terms"] \ + -variable ::dialog_helpbrowser2::matchall -style Search.TCheckbutton + ttk::checkbutton $mytoplevel.f.matchwords_check -text [_ "Match whole words"] \ + -variable ::dialog_helpbrowser2::matchwords -style Search.TCheckbutton + ttk::label $mytoplevel.f.advancedlabel -text [_ "Help"] -foreground "#0000ff" \ + -anchor center -style Foo.TLabel + text $mytoplevel.navtext -font "$searchfont 12" -height 1 -bd 0 -highlightthickness 0\ + -padx 8 -pady 3 -bg white -fg black + text $mytoplevel.resultstext -yscrollcommand "$mytoplevel.yscrollbar set" \ + -bg white -highlightcolor blue -height 30 -wrap word -state disabled \ + -padx 8 -pady 3 -spacing3 2 -bd 0 -highlightthickness 0 -fg black + ttk::scrollbar $mytoplevel.yscrollbar -command "$mytoplevel.resultstext yview" \ + -takefocus 0 + ttk::label $mytoplevel.statusbar -text [_ "Pure Data Search"] -justify left \ + -padding {4 4 4 4} + + grid $mytoplevel.f.searchtextentry -column 0 -columnspan 3 -row 0 -padx 3 \ + -pady 2 -sticky ew + grid $mytoplevel.f.searchbutton -column 3 -columnspan 2 -row 0 -padx 3 \ + -sticky ew + grid $mytoplevel.f.genrebox -column 0 -row 1 -padx 3 -sticky w + grid $mytoplevel.f.matchall_check -column 1 -row 1 -padx 3 -sticky w + grid $mytoplevel.f.matchwords_check -column 2 -row 1 -padx 3 -sticky w + grid $mytoplevel.f.advancedlabel -column 3 -columnspan 2 -row 1 -sticky ew + grid $mytoplevel.f -column 0 -columnspan 5 -row 0 -sticky ew + grid $mytoplevel.navtext -column 0 -columnspan 5 -row 2 -sticky nsew + grid $mytoplevel.resultstext -column 0 -columnspan 4 -row 3 -sticky nsew -ipady 0 -pady 0 + grid $mytoplevel.yscrollbar -column 4 -row 3 -sticky nsew + grid $mytoplevel.statusbar -column 0 -columnspan 4 -row 4 -sticky nsew + grid columnconfigure $mytoplevel.f 0 -weight 0 + grid columnconfigure $mytoplevel.f 1 -weight 0 + grid columnconfigure $mytoplevel.f 2 -weight 1 + grid columnconfigure $mytoplevel.f 3 -weight 0 + grid columnconfigure $mytoplevel 0 -weight 1 + grid columnconfigure $mytoplevel 4 -weight 0 + grid rowconfigure $mytoplevel 2 -weight 0 + grid rowconfigure $mytoplevel 3 -weight 1 + # tags + $mytoplevel.resultstext tag configure hide -elide on + $mytoplevel.navtext tag configure is_libdir -elide on + $mytoplevel.resultstext tag configure is_libdir -elide on + $mytoplevel.resultstext tag configure title -foreground "#0000ff" -underline on \ + -font "$searchfont 12" -spacing1 6 + $mytoplevel.resultstext tag configure dir_title -font "$searchfont 12" \ + -underline on -spacing1 6 + $mytoplevel.resultstext tag configure filename -elide on + $mytoplevel.navtext tag configure filename -elide on + $mytoplevel.resultstext tag configure metakey -font "$searchfont 10" + $mytoplevel.resultstext tag configure metavalue_h -elide on + $mytoplevel.resultstext tag configure basedir -elide on + $mytoplevel.navtext tag configure basedir -elide on + $mytoplevel.resultstext tag configure description -font "$searchfont 12" + $mytoplevel.resultstext tag configure homepage_title -font "$searchfont 12" \ + -underline on -spacing1 10 -spacing3 5 + $mytoplevel.navtext tag configure homepage_title -underline on + $mytoplevel.resultstext tag configure homepage_description -font "$searchfont 12" \ + -spacing3 7 + $mytoplevel.resultstext tag configure intro_libdirs -font "$searchfont 12" + # make tags for both the results and the nav text widgets + foreach textwidget [list "$mytoplevel.resultstext" "$mytoplevel.navtext"] { + $textwidget tag configure link -foreground "#0000ff" + $textwidget tag bind link "$textwidget configure \ + -cursor hand2" + $textwidget tag bind link "$textwidget configure \ + -cursor xterm; $mytoplevel.statusbar configure -text \"\"" + $textwidget tag bind intro "::dialog_helpbrowser2::intro \ + $mytoplevel.resultstext" + $textwidget tag bind intro "$mytoplevel.statusbar \ + configure -text \"Go back to the main help page\"" + $textwidget tag bind intro "$mytoplevel.statusbar \ + configure -text \"\"" + $textwidget tag bind libdirs "::dialog_helpbrowser2::build_libdirs \ + $mytoplevel.resultstext" + $textwidget tag bind libdirs "$mytoplevel.statusbar configure \ + -text \"Browse all external libraries that have the libdir format\"" + $textwidget tag bind libdirs "$mytoplevel.statusbar configure \ + -text \"\"" + } + # hack to force new events for tags and links next to each other + for {set i 0} {$i<30} {incr i} { + $mytoplevel.resultstext tag bind "metavalue$i" \ + "::dialog_helpbrowser2::grab_metavalue %x %y $mytoplevel 1" + $mytoplevel.resultstext tag bind "metavalue$i" \ + "::dialog_helpbrowser2::grab_metavalue %x %y $mytoplevel 0" + $mytoplevel.resultstext tag bind "intro_link$i" \ + "::dialog_helpbrowser2::open_file %x %y $mytoplevel resultstext dir 0" + $mytoplevel.resultstext tag bind "intro_link$i" \ + "$mytoplevel.statusbar configure -text \"\"" + $mytoplevel.resultstext tag configure "metavalue$i" -font \ + "$searchfont 12" + $mytoplevel.resultstext tag configure "intro_link$i" -font \ + "$searchfont 12" + $mytoplevel.resultstext tag bind "dir_title$i" \ + "::dialog_helpbrowser2::open_file %x %y $mytoplevel resultstext dir 0" + $mytoplevel.resultstext tag bind "dir_title$i" \ + "$mytoplevel.resultstext configure -cursor xterm; \ + $mytoplevel.statusbar configure -text \"\"" + $mytoplevel.resultstext tag configure "dir_title$i" \ + -font "$searchfont 12" -underline on -spacing1 6 + } + # this next tag configure comes after the metavalue stuff above so + # that it has a higher priority (these are the keywords in the search + # results) + $mytoplevel.resultstext tag configure keywords -font "$searchfont 10" + $mytoplevel.resultstext tag configure homepage_file -font "$searchfont 12" + $mytoplevel.resultstext tag bind homepage_file "::dialog_helpbrowser2::open_file \ + %x %y $mytoplevel resultstext file 1" + $mytoplevel.resultstext tag bind homepage_file "::dialog_helpbrowser2::open_file \ + %x %y $mytoplevel resultstext file 0" + $mytoplevel.resultstext tag bind homepage_file "$mytoplevel.statusbar configure \ + -text \"\"" + $mytoplevel.resultstext tag bind title "::dialog_helpbrowser2::open_file %x %y \ + $mytoplevel resultstext file 1" + $mytoplevel.resultstext tag bind title "::dialog_helpbrowser2::open_file %x %y \ + $mytoplevel resultstext file 0" + $mytoplevel.resultstext tag bind dir_title "::dialog_helpbrowser2::open_file %x %y \ + $mytoplevel resultstext dir 0" + $mytoplevel.resultstext tag bind dir_title "$mytoplevel.resultstext configure \ + -cursor xterm; $mytoplevel.statusbar configure -text \"\"" + $mytoplevel.resultstext tag bind help_icon "::dialog_helpbrowser2::get_info %x %y \ + $mytoplevel" + $mytoplevel.resultstext tag bind help_icon "$mytoplevel.resultstext configure \ + -cursor hand2; $mytoplevel.statusbar configure -text \"Get info on this object's\ + libdir\"" + $mytoplevel.resultstext tag bind help_icon "$mytoplevel.resultstext configure \ + -cursor xterm; $mytoplevel.statusbar configure -text \"\"" + $mytoplevel.resultstext tag bind folder_icon "::dialog_helpbrowser2::open_file %x %y \ + $mytoplevel resultstext dir_in_fm 1" + $mytoplevel.resultstext tag bind folder_icon "::dialog_helpbrowser2::open_file %x %y \ + $mytoplevel resultstext dir_in_fm 0" + $mytoplevel.resultstext tag bind folder_icon "$mytoplevel.resultstext configure \ + -cursor xterm; $mytoplevel.statusbar configure -text \"\"" + foreach textwidget [list "$mytoplevel.resultstext" "$mytoplevel.navtext"] { + $textwidget tag bind clickable_dir "::dialog_helpbrowser2::click_dir \ + $textwidget %x %y" + } + # another workaround: we can't just do a mouseover statusbar update with clickable_dir + # since it wouldn't register an event when moving the mouse from one dir to an + # adjacent dir. So we have the intro_link$i hack above PLUS a separate binding for navbar + # links (which are not adjacent) + $mytoplevel.navtext tag bind navbar_dir "::dialog_helpbrowser2::open_file %x %y \ + $mytoplevel navtext dir 0" + $mytoplevel.navtext tag bind navbar_dir "$mytoplevel.statusbar configure \ + -text \"\"" + + # search window widget bindings + bind $mytoplevel <$::modifier-equal> "::dialog_helpbrowser2::font_size $mytoplevel.resultstext 1" + bind $mytoplevel <$::modifier-plus> "::dialog_helpbrowser2::font_size $mytoplevel.resultstext 1" + bind $mytoplevel <$::modifier-minus> "::dialog_helpbrowser2::font_size $mytoplevel.resultstext 0" + bind $mytoplevel.f.searchtextentry "$mytoplevel.f.searchbutton invoke" + bind $mytoplevel.f.searchtextentry <$::modifier-Key-BackSpace> \ + "::dialog_helpbrowser2::ctrl_bksp $mytoplevel.f.searchtextentry" + bind $mytoplevel.f.searchtextentry <$::modifier-Key-a> \ + "$mytoplevel.f.searchtextentry selection range 0 end; break" + bind $mytoplevel.f.genrebox <> "::dialog_helpbrowser2::filter_results \ + $mytoplevel.f.genrebox $mytoplevel.resultstext" + bind $mytoplevel.f.matchall_check "$mytoplevel.f.searchbutton invoke" + bind $mytoplevel.f.matchwords_check "$mytoplevel.f.searchbutton invoke" + bind $mytoplevel.f.advancedlabel "$mytoplevel.f.advancedlabel configure \ + -cursor hand2; $mytoplevel.statusbar configure -text \"Advanced search options\"" + bind $mytoplevel.f.advancedlabel "$mytoplevel.f.advancedlabel configure \ + -cursor xterm; $mytoplevel.statusbar configure -text \"\"" + bind $mytoplevel.f.advancedlabel \ + {menu_doc_open doc/5.reference all_about_finding_objects.pd} +# Right now we're suppressing dialog bindings because helpbrowser namespace +# doesn't work unless all procs are prefixed with dialog_ + ::pd_bindings::dialog_bindings $mytoplevel "helpbrowser2" +# bind $mytoplevel "helpbrowser2::cancel $mytoplevel" +# bind $mytoplevel "helpbrowser2::ok $mytoplevel" +# bind $mytoplevel <$::modifier-Key-w> "helpbrowser2::cancel $mytoplevel" + # these aren't supported in the dialog, so alert the user, then break so + # that no other key bindings are run + bind $mytoplevel <$::modifier-Key-s> {bell; break} + bind $mytoplevel <$::modifier-Shift-Key-S> {bell; break} + bind $mytoplevel <$::modifier-Key-p> {bell; break} -# TODO check line formatting options + bind $mytoplevel <$::modifier-Key-f> "break" + + # Add state and set focus + $mytoplevel.f.searchtextentry insert 0 "Enter search terms" + $mytoplevel.f.searchtextentry selection range 0 end + # go ahead and set tags for the default genre + filter_results $mytoplevel.f.genrebox $mytoplevel.resultstext + focus $mytoplevel.f.searchtextentry + ::dialog_helpbrowser2::intro $mytoplevel.resultstext + set ::dialog_helpbrowser2::matchall 1 + set ::dialog_helpbrowser2::matchwords 1 +} # find_doc_files # basedir - the directory to start looking in -proc ::dialog_search::find_doc_files { basedir recursive } { +proc ::dialog_helpbrowser2::find_doc_files { basedir recursive } { # Fix the directory name, this ensures the directory name is in the # native format for the platform and contains a final directory seperator set basedir [string trimright [file join $basedir { }]] @@ -72,8 +309,8 @@ proc ::dialog_search::find_doc_files { basedir recursive } { return $fileList } -proc ::dialog_search::open_file { xpos ypos mytoplevel type clicked } { - set textwidget "$mytoplevel.resultstext" +proc ::dialog_helpbrowser2::open_file { xpos ypos mytoplevel text type clicked } { + set textwidget [join [list $mytoplevel $text] .] set i [$textwidget index @$xpos,$ypos] set range [$textwidget tag nextrange filename $i] set filename [eval $textwidget get $range] @@ -88,8 +325,8 @@ proc ::dialog_search::open_file { xpos ypos mytoplevel type clicked } { } else { $mytoplevel.resultstext configure -cursor hand2 if {$type eq "file"} { - $mytoplevel.statusbar configure -text \ - [format [_ "Open %s"] [file join $basedir $filename]] + $mytoplevel.statusbar configure -text \ + [format [_ "Open %s"] [file join $basedir $filename]] } else { set msg "" if {$type eq "dir_in_fm"} {set msg {in external file browser: }} @@ -100,7 +337,7 @@ proc ::dialog_search::open_file { xpos ypos mytoplevel type clicked } { } # only does keywords for now-- maybe expand this to handle any meta tags -proc ::dialog_search::grab_metavalue { xpos ypos mytoplevel clicked } { +proc ::dialog_helpbrowser2::grab_metavalue { xpos ypos mytoplevel clicked } { set textwidget "$mytoplevel.resultstext" set i [$textwidget index @$xpos,$ypos] set range [$textwidget tag nextrange metavalue_h $i] @@ -111,22 +348,24 @@ proc ::dialog_search::grab_metavalue { xpos ypos mytoplevel clicked } { set key [string tolower $key] append text $key {[^;]*} $value {.*?;} if {$clicked eq "1"} { - ::dialog_search::searchfor $text + ::dialog_helpbrowser2::searchfor $text } else { $mytoplevel.statusbar configure -text [format [_ "Search for pattern: %s"] $text] } } -proc ::dialog_search::searchfor {text} { - set ::dialog_search::searchtext "" - set ::dialog_search::searchtext $text - ::dialog_search::search +proc ::dialog_helpbrowser2::searchfor {text} { + set ::dialog_helpbrowser2::searchtext "" + set ::dialog_helpbrowser2::searchtext $text + ::dialog_helpbrowser2::search } # show/hide results based on genre -proc ::dialog_search::filter_results { combobox text } { +proc ::dialog_helpbrowser2::filter_results { combobox text } { variable genres + # hack to add the navbar text widget + foreach text [list "$text" .helpbrowser2.navtext] { set elide {} if { [$combobox current] eq "0" } { foreach genre $genres { @@ -153,11 +392,12 @@ proc ::dialog_search::filter_results { combobox text } { } } } + } $combobox selection clear focus $text } -proc ::dialog_search::readfile {filename} { +proc ::dialog_helpbrowser2::readfile {filename} { set fp [open $filename] set file_contents [split [read $fp] \n] close $fp @@ -173,8 +413,8 @@ proc ::dialog_search::readfile {filename} { # "quoting hell" and just convert lists to # strings, I figure I owe the user a polite # explanation if they run into trouble -proc ::dialog_search::error { fid error_type } { - set widget .search.resultstext +proc ::dialog_helpbrowser2::error { fid error_type } { + set widget .helpbrowser2.resultstext $widget configure -state normal $widget delete 0.0 end print_navbar $widget @@ -205,58 +445,64 @@ proc ::dialog_search::error { fid error_type } { $widget configure -state disabled } -proc ::dialog_search::search { } { +proc ::dialog_helpbrowser2::search { } { variable searchtext variable search_history variable progress + variable navbar # Catch search text that isn't a proper list or # will break a regex before they cause any trouble if {[catch {llength $searchtext} fid]} { - ::dialog_search::error $fid "badlist" + ::dialog_helpbrowser2::error $fid "badlist" return } elseif {[catch {regexp $searchtext "foo"} fid]} { - ::dialog_search::error $fid "badregex" + ::dialog_helpbrowser2::error $fid "badregex" return } if {$searchtext eq ""} return if { [lsearch $search_history $searchtext] eq "-1" } { lappend search_history $searchtext - .search.searchtextentry configure -values $search_history + .helpbrowser2.f.searchtextentry configure -values $search_history } - .search.searchtextentry selection clear - .search.searchtextentry configure -foreground gray -background gray90 - .search.resultstext configure -state normal - .search.resultstext delete 0.0 end - set widget .search.resultstext + .helpbrowser2.f.searchtextentry selection clear + .helpbrowser2.f.searchtextentry configure -foreground gray -background gray90 + .helpbrowser2.resultstext configure -state normal + .helpbrowser2.navtext configure -state normal + .helpbrowser2.resultstext delete 0.0 end + .helpbrowser2.navtext delete 0.0 end + set widget .helpbrowser2.navtext + set navbar {} print_navbar $widget + $widget configure -state normal $widget insert 1.end " " - ttk::progressbar $widget.pbar -variable ::dialog_search::progress \ + ttk::progressbar $widget.pbar -variable ::dialog_helpbrowser2::progress \ -mode determinate $widget window create 1.end -window $widget.pbar - ::dialog_search::do_search + $widget configure -state disabled + ::dialog_helpbrowser2::do_search # todo: re-read http://wiki.tcl.tk/1526 - # after idle [list after 10 ::dialog_search::do_search] + # after idle [list after 10 ::dialog_helpbrowser2::do_search] } -proc ::dialog_search::do_search { } { +proc ::dialog_helpbrowser2::do_search { } { variable searchtext variable formatted_searchtext variable count {} variable progress 0 variable genres variable filelist {} - variable navbar {} variable i 0 + variable cancelled 0 foreach genre $genres { lappend count 0 } - set widget .search.resultstext # Get rid of pesky leading/trailing spaces... set formatted_searchtext [string trim $searchtext] # ...and double spaces between terms regsub -all {\s+} $formatted_searchtext { } formatted_searchtext - foreach basedir [concat [file join $::sys_libdir doc] $::sys_searchpath $::sys_staticpath] { + 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 # native format for the platform and contains a final directory seperator set basedir [file normalize $basedir] @@ -266,14 +512,15 @@ proc ::dialog_search::do_search { } { } } set filelist [searchfile_sort $filelist] - ::dialog_search::search_and_update + ::dialog_helpbrowser2::search_and_update } -proc ::dialog_search::results_epilog {widget} { +proc ::dialog_helpbrowser2::results_epilog {widget} { variable genres variable count variable filelist - .search.searchtextentry configure -foreground black -background white + .helpbrowser2.f.searchtextentry configure -foreground black -background white + $widget configure -state normal $widget delete {1.0 lineend -1 chars} 1.end $widget insert 1.end [_ "Found "] "navbar" set i 0 @@ -284,26 +531,28 @@ proc ::dialog_search::results_epilog {widget} { incr i } $widget insert 1.end \ - [format [_ " matches out of %s docs"] [llength $filelist]] "navbar" + [format [_ " out of %s docs"] [llength $filelist]] "navbar" $widget configure -state disabled + .helpbrowser2.resultstext configure -state disabled } # Recursive loop to search all files and keep the gui # alive every 256 iterations. This was tested searching # a little over 9,000 docs and seems to work alright -proc ::dialog_search::search_and_update {} { +proc ::dialog_helpbrowser2::search_and_update {} { variable formatted_searchtext variable filelist variable progress variable i + variable cancelled if { $i < [llength $filelist]} { # get index of docfile docname and basedir set docname [lindex $filelist $i 0] set docfile [lindex $filelist $i 1] set basedir [lindex $filelist $i 2] # send it to searchfile - ::dialog_search::searchfile $formatted_searchtext \ - [readfile $docfile] ".search.resultstext" $docname \ + ::dialog_helpbrowser2::searchfile $formatted_searchtext \ + [readfile $docfile] ".helpbrowser2.resultstext" $docname \ $basedir incr i # I changed '256' below to [llength $filelist]/8 in order @@ -311,20 +560,30 @@ proc ::dialog_search::search_and_update {} { # of files and tcl complained there were too many nested # loops. Hm... if { $i%256==0 } { - # update the progressbar variable and refresh gui - set progress [expr $i*100.0/[llength $filelist]] - after idle ::dialog_search::search_and_update - } else { ::dialog_search::search_and_update } + # if the user closed the window then quit searching. I'm + # using a global variable here in case we want to veer from + # the standard dialog behavior and stop a search with ESC + # without actually withdrawing the window + if { $cancelled == 0 } { + # update the progressbar variable and refresh gui + set progress [expr $i*100.0/[llength $filelist]] + after idle ::dialog_helpbrowser2::search_and_update + } else { + ::dialog_helpbrowser2::results_epilog ".helpbrowser2.navtext" + return + } + } else { ::dialog_helpbrowser2::search_and_update } } else { # we've gone throught the whole filelist so end the recursion set progress 100 - ::dialog_search::results_epilog ".search.resultstext" + ::dialog_helpbrowser2::results_epilog ".helpbrowser2.navtext" return } } # put all the stuff in 5.reference at the top of the results -proc ::dialog_search::searchfile_sort { list } { +proc ::dialog_helpbrowser2::searchfile_sort { list } { + if {$list eq ""} {return} foreach triple $list { regsub {.*5\.reference[\\\/](.*)} [lindex $triple 0] { \1} key lappend list2 [list $key $triple] @@ -336,7 +595,7 @@ proc ::dialog_search::searchfile_sort { list } { } # put license.txt and readme.txt at the bottom of a directory listing -proc ::dialog_search::directory_sort { list } { +proc ::dialog_helpbrowser2::directory_sort { list } { if {$list eq ""} {return} foreach name $list { regsub -nocase {(license\.txt|readme\.txt)} $name {~~~\1} key @@ -348,12 +607,12 @@ proc ::dialog_search::directory_sort { list } { return $list3 } -proc ::dialog_search::searchfile {searchtext file_contents widget filename basedir} { +proc ::dialog_helpbrowser2::searchfile {searchtext file_contents widget filename basedir} { variable count variable genres set match 0 set terms_to_match 1 - if { $::dialog_search::matchall == 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. @@ -361,7 +620,7 @@ proc ::dialog_search::searchfile {searchtext file_contents widget filename based set lb {(?:^|[^[:alnum:]_])} set rb {(?![[:alnum:]_~])} foreach term $searchtext { - if {$::dialog_search::matchwords == 1} { + if {$::dialog_helpbrowser2::matchwords == 1} { set term [join [list $lb $term $rb] ""] } if {[regexp -nocase -- $term $filename] || @@ -370,11 +629,11 @@ proc ::dialog_search::searchfile {searchtext file_contents widget filename based } } if { $match >= $terms_to_match } { - ::dialog_search::printresult $filename $basedir $file_contents $widget 1 + ::dialog_helpbrowser2::printresult $filename $basedir $file_contents $widget 1 } } -proc ::dialog_search::printresult {filename basedir file_contents widget mixed_dirs} { +proc ::dialog_helpbrowser2::printresult {filename basedir file_contents widget mixed_dirs} { variable count variable genres set description "" @@ -422,10 +681,10 @@ proc ::dialog_search::printresult {filename basedir file_contents widget mixed_d if {$mixed_dirs} { if { $genre == 1 } { $widget insert end " " - $widget image create end -image ::dialog_search::help + $widget image create end -image ::dialog_helpbrowser2::help } $widget insert end " " - $widget image create end -image ::dialog_search::folder + $widget image create end -image ::dialog_helpbrowser2::folder if { $genre == 1 } { $widget tag add help_icon "end -4indices" "end -3indices" $widget tag add $genre_name "end -5indices" end @@ -457,32 +716,29 @@ proc ::dialog_search::printresult {filename basedir file_contents widget mixed_d } } -proc ::dialog_search::ok {mytoplevel} { +proc ::dialog_helpbrowser2::ok {mytoplevel} { # this is a placeholder for the standard dialog bindings } -proc ::dialog_search::cancel {mytoplevel} { - wm withdraw .search +proc ::dialog_helpbrowser2::cancel {mytoplevel} { + variable cancelled 1 + wm withdraw .helpbrowser2 } -proc ::dialog_search::open_search_dialog {mytoplevel} { - if {[winfo exists $mytoplevel]} { - wm deiconify $mytoplevel - raise $mytoplevel - } else { - create_dialog $mytoplevel - } -} # hack to select all because tk's default bindings apparently # assume the user is going to want emacs shortcuts -proc ::dialog_search::sa { widget } { +proc ::dialog_helpbrowser2::sa { widget } { $widget selection range 0 end break } -proc ::dialog_search::intro { t } { +proc ::dialog_helpbrowser2::intro { t } { variable navbar {} + .helpbrowser2.navtext configure -state normal + .helpbrowser2.navtext delete 0.0 end + .helpbrowser2.navtext insert end "Search" "navbar homepage_title" + .helpbrowser2.navtext configure -state disabled $t configure -state normal $t delete 0.0 end $t insert end [_ "Enter terms above. Use the dropdown "] homepage_description @@ -493,7 +749,7 @@ proc ::dialog_search::intro { t } { $t insert end "0" is_libdir $t insert end "\n" description $t insert end [_ "External Pd libraries\n"] "link libdirs intro_libdirs" - $t insert end [_ "Introductory Topics\n"] homepage_title + $t insert end [_ "Browse Introductory Topics\n"] homepage_title set intro_docs { \ "Pd Manual" 1.manual "HTML manual for Pure Data" \ "Control Structure" 2.control.examples "tutorials for control objects" \ @@ -513,7 +769,7 @@ proc ::dialog_search::intro { t } { $t insert end all_about.pd filename $t insert end [_ " reference patches for key concepts and settings\ in Pd\n"] description - $t insert end [_ "Advanced Topics\n"] homepage_title + $t insert end [_ "Browse Advanced Topics\n"] homepage_title set advanced_docs [list \ [_ "Networking"] [file join manuals 3.Networking] [_ "sending data over networks with Pd"] \ [_ "Writing Externals"] 6.externs [_ "how to code control and signal objects in C"] \ @@ -532,7 +788,7 @@ proc ::dialog_search::intro { t } { $t insert end " $desc\n" description set i [expr {($i+1)%30}] } - $t insert end [_ "Keywords\n"] homepage_title + $t insert end [_ "Keyword Search\n"] homepage_title $t insert end [_ "Many of the help documents are categorized by keyword. Click\ a link below to search for documents that have been tagged with that\ keyword.\n"] \ @@ -552,8 +808,8 @@ proc ::dialog_search::intro { t } { {data_structure "create or manage data structures"} \ {dynamic_patching "dynamic instantiation/deletion\ of objects or patches"} \ - {filesystem "object that reads to and/or writes from the\ - filesystem"} \ + {filesystem "object that reads from and/or writes to the\ + file system"} \ {filter "object that filters incoming data"} \ {GUI "graphical user interface"} \ {list_op "object that manipulates, outputs, or stores a list"} \ @@ -590,7 +846,7 @@ proc ::dialog_search::intro { t } { } # hack to get to delete the word to the left of the cursor -proc ::dialog_search::ctrl_bksp {mytoplevel} { +proc ::dialog_helpbrowser2::ctrl_bksp {mytoplevel} { set last [$mytoplevel index insert] set first $last while { $first > 0 } { @@ -606,7 +862,7 @@ proc ::dialog_search::ctrl_bksp {mytoplevel} { $mytoplevel delete $first $last } -proc ::dialog_search::font_size {text direction} { +proc ::dialog_helpbrowser2::font_size {text direction} { variable searchfont set offset {} set min_fontsize 8 @@ -634,7 +890,7 @@ proc ::dialog_search::font_size {text direction} { } } -proc ::dialog_search::build_libdirs {textwidget} { +proc ::dialog_helpbrowser2::build_libdirs {textwidget} { set libdirs {} foreach pathdir [concat $::sys_searchpath $::sys_staticpath] { if { ! [file isdirectory $pathdir]} {continue} @@ -651,14 +907,14 @@ proc ::dialog_search::build_libdirs {textwidget} { } } } - ::dialog_search::print_libdirs $textwidget $libdirs + ::dialog_helpbrowser2::print_libdirs $textwidget $libdirs } -proc ::dialog_search::print_libdirs {textwidget libdirs} { - variable navbar {} +proc ::dialog_helpbrowser2::print_libdirs {textwidget libdirs} { + variable navbar $textwidget configure -state normal $textwidget delete 0.0 end - lappend navbar [list [_ "External libraries"] "link libdirs navbar" {}] + set navbar [list [list [_ "External libraries"] "link libdirs navbar" {}]] print_navbar $textwidget # now clear out the navbar and then add "externals (flag) to it..." set i 0 @@ -668,7 +924,7 @@ proc ::dialog_search::print_libdirs {textwidget libdirs} { set author {} $textwidget insert end "[lindex $libdir 1]" "link clickable_dir dir_title$i" $textwidget insert end " " - $textwidget image create end -image ::dialog_search::folder + $textwidget image create end -image ::dialog_helpbrowser2::folder $textwidget tag add folder_icon "end -2indices" "end -1indices" $textwidget insert end "[lindex $libdir 0]" basedir $textwidget insert end "dummy" filename @@ -698,16 +954,16 @@ proc ::dialog_search::print_libdirs {textwidget libdirs} { $textwidget configure -state disabled } -proc ::dialog_search::click_dir {textwidget xpos ypos} { +proc ::dialog_helpbrowser2::click_dir {textwidget xpos ypos} { set i [$textwidget index @$xpos,$ypos] set range [$textwidget tag nextrange basedir $i] set dir [eval $textwidget get $range] set range [$textwidget tag nextrange is_libdir $i] set is_libdir [eval $textwidget get $range] - build_subdir $textwidget $dir $is_libdir + build_subdir .helpbrowser2.resultstext $dir $is_libdir } -proc ::dialog_search::build_subdir {textwidget dir is_libdir} { +proc ::dialog_helpbrowser2::build_subdir {textwidget dir is_libdir} { variable navbar if {[lsearch -exact [join $navbar] $dir] == -1} { lappend navbar [list "$dir" "link clickable_dir navbar navbar_dir" "subdir"] @@ -721,7 +977,7 @@ proc ::dialog_search::build_subdir {textwidget dir is_libdir} { } $textwidget configure -state normal $textwidget delete 0.0 end - print_navbar $textwidget + print_navbar .helpbrowser2.navtext # get any subdirs first set i 0 foreach subdir [lsort -dictionary [glob -nocomplain -type d -directory $dir "*"]] { @@ -731,7 +987,7 @@ proc ::dialog_search::build_subdir {textwidget dir is_libdir} { set norm_subdir [string trimright [file join [file normalize $subdir] { }]] $textwidget insert end "0" is_libdir $textwidget insert end " " - $textwidget image create end -image ::dialog_search::folder + $textwidget image create end -image ::dialog_helpbrowser2::folder $textwidget tag add folder_icon "end -2indices" "end -1indices" $textwidget insert end "$norm_subdir" basedir $textwidget insert end "dummy" filename @@ -745,18 +1001,24 @@ proc ::dialog_search::build_subdir {textwidget dir is_libdir} { [string replace $docfile 0 [expr [string length $docfile] - 4]] ne ".pd" || !$is_libdir} { set docname [string replace $docfile 0 [string length [file normalize $dir]]] - ::dialog_search::printresult $docname $dir [readfile $docfile] $textwidget 0 + ::dialog_helpbrowser2::printresult $docname $dir [readfile $docfile] $textwidget 0 } } $textwidget configure -state disabled } -proc ::dialog_search::print_navbar {text} { +# fix this-- maybe print_navbar shouldn't need an argument +proc ::dialog_helpbrowser2::print_navbar {foo} { variable navbar - set separator - - $text insert 1.0 "\n" navbar + set separator / + set text .helpbrowser2.navtext + $text configure -state normal + $text delet 1.0 end $text insert 1.0 [_ "Home"] "link intro navbar" - if {[llength $navbar] == 0} {return} + if {[llength $navbar] == 0} { + $text configure -state disabled + return + } for {set i 0} {$i<[expr {[llength $navbar]-1}]} {incr i} { $text insert 1.end " $separator " navbar if {[lindex $navbar $i 2] eq "subdir"} { @@ -776,9 +1038,10 @@ proc ::dialog_search::print_navbar {text} { $text insert 1.end " $separator " navbar $text insert 1.end [lindex $navbar end 0] } + $text configure -state disabled } -proc ::dialog_search::get_info {xpos ypos mytoplevel} { +proc ::dialog_helpbrowser2::get_info {xpos ypos mytoplevel} { set textwidget "$mytoplevel.resultstext" set i [$textwidget index @$xpos,$ypos] set range [$textwidget tag nextrange filename $i] @@ -805,216 +1068,24 @@ proc ::dialog_search::get_info {xpos ypos mytoplevel} { } if {!$match} { tk_messageBox -message \ - [_ "Sorry, can't find a README file for this object's library." \ - -title [_ "Search"] + [_ "Sorry, can't find a README file for this object's library."] \ + -title [_ "Search"] } } -proc ::dialog_search::create_dialog {mytoplevel} { - variable searchfont - variable selected_file - variable genres - variable count - foreach genre $genres { - lappend count 0 - } - toplevel $mytoplevel -class DialogWindow - wm title $mytoplevel [_ "Search"] - wm geometry $mytoplevel 670x550+0+30 - # style tweak: get rid of arrow so the combobox looks like a simple entry widget - ttk::style configure Entry.TCombobox -arrowsize 0 - ttk::style configure Genre.TCombobox - ttk::style configure Search.TButton -font menufont - ttk::style configure Search.TCheckbutton -font menufont - # widgets - # for some reason ttk widgets didn't inherit the menufont, and this causes tiny - # fonts on Windows-- so let's hack! - foreach widget {f.genrebox advancedlabel } { - option add *[string trim "$mytoplevel.$widget" .]*font menufont - } - foreach combobox {searchtextentry f.genrebox} { - option add *[string trim "$mytoplevel.$combobox" .]*Listbox.font menufont - } - ttk::combobox $mytoplevel.searchtextentry -textvar ::dialog_search::searchtext \ - -font "$searchfont 12" -style "Entry.TCombobox" -cursor "xterm" - ttk::button $mytoplevel.searchbutton -text [_ "Search"] -takefocus 0 \ - -command ::dialog_search::search -style Search.TButton - ttk::frame $mytoplevel.f -padding 2 - ttk::combobox $mytoplevel.f.genrebox -values $genres -state readonly -style "Genre.TCombobox" - $mytoplevel.f.genrebox current 0 - ttk::checkbutton $mytoplevel.f.matchall_check -text [_ "Match all terms"] \ - -variable ::dialog_search::matchall -style Search.TCheckbutton - ttk::checkbutton $mytoplevel.f.matchwords_check -text [_ "Match whole words"] \ - -variable ::dialog_search::matchwords -style Search.TCheckbutton - ttk::label $mytoplevel.advancedlabel -text [_ "Help"] -foreground "#0000ff" \ - -anchor center - text $mytoplevel.resultstext -yscrollcommand "$mytoplevel.yscrollbar set" \ - -bg white -highlightcolor blue -height 30 -wrap word -state disabled \ - -padx 8 -pady 4 -spacing3 2 - ttk::scrollbar $mytoplevel.yscrollbar -command "$mytoplevel.resultstext yview" \ - -takefocus 0 - ttk::label $mytoplevel.statusbar -text [_ "Pure Data Search"] -justify left \ - -padding {4 4 4 4} - - grid $mytoplevel.f.genrebox $mytoplevel.f.matchall_check \ - $mytoplevel.f.matchwords_check -padx 3 - grid $mytoplevel.searchtextentry -column 0 -columnspan 3 -row 0 -padx 3 -pady 2 -sticky ew - grid $mytoplevel.searchbutton -column 3 -columnspan 1 -row 0 -padx 3 -sticky ew - grid $mytoplevel.f -column 0 -columnspan 3 -row 1 -sticky we - grid $mytoplevel.advancedlabel -column 3 -columnspan 1 -row 1 -sticky ew - grid $mytoplevel.resultstext -column 0 -columnspan 4 -row 2 -sticky nsew - grid $mytoplevel.yscrollbar -column 4 -row 2 -sticky nsew - grid $mytoplevel.statusbar -column 0 -columnspan 4 -row 3 -sticky nsew - grid columnconfigure $mytoplevel 0 -weight 1 - grid columnconfigure $mytoplevel 4 -weight 0 - grid rowconfigure $mytoplevel 2 -weight 1 - - # tags - $mytoplevel.resultstext tag configure hide -elide on - $mytoplevel.resultstext tag configure is_libdir -elide on - $mytoplevel.resultstext tag configure title -foreground "#0000ff" -underline on \ - -font "$searchfont 12" -spacing1 6 - $mytoplevel.resultstext tag configure dir_title -font "$searchfont 12" \ - -underline on -spacing1 6 - $mytoplevel.resultstext tag configure filename -elide on - $mytoplevel.resultstext tag configure metakey -font "$searchfont 10" - $mytoplevel.resultstext tag configure metavalue_h -elide on - $mytoplevel.resultstext tag configure basedir -elide on - $mytoplevel.resultstext tag configure description -font "$searchfont 12" - $mytoplevel.resultstext tag configure homepage_title -font "$searchfont 12" \ - -underline on -spacing1 10 -spacing3 5 - $mytoplevel.resultstext tag configure homepage_description -font "$searchfont 12" \ - -spacing3 7 - $mytoplevel.resultstext tag configure navbar -font "$searchfont 12" \ - -spacing1 8 -spacing3 5 - $mytoplevel.resultstext tag configure intro_libdirs -font "$searchfont 12" - # create a bunch of link bindings so that you get and - # events when two links are right next to each other - $mytoplevel.resultstext tag configure link -foreground "#0000ff" - $mytoplevel.resultstext tag bind link "$mytoplevel.resultstext configure \ - -cursor hand2" - $mytoplevel.resultstext tag bind link "$mytoplevel.resultstext configure \ - -cursor xterm; $mytoplevel.statusbar configure -text \"\"" - $mytoplevel.resultstext tag bind intro "::dialog_search::intro \ - $mytoplevel.resultstext" - $mytoplevel.resultstext tag bind intro "$mytoplevel.statusbar \ - configure -text \"[_ {Go back to the main help page}]\"" - $mytoplevel.resultstext tag bind intro "$mytoplevel.statusbar \ - configure -text \"\"" - $mytoplevel.resultstext tag bind libdirs "::dialog_search::build_libdirs \ - $mytoplevel.resultstext" - $mytoplevel.resultstext tag bind libdirs "$mytoplevel.statusbar configure \ - -text \"[_ {Browse all external libraries that have the libdir format}]\"" - $mytoplevel.resultstext tag bind libdirs "$mytoplevel.statusbar configure \ - -text \"\"" - # hack to force new events for tags and links next to each other - for {set i 0} {$i<30} {incr i} { - $mytoplevel.resultstext tag bind "metavalue$i" \ - "::dialog_search::grab_metavalue %x %y $mytoplevel 1" - $mytoplevel.resultstext tag bind "metavalue$i" \ - "::dialog_search::grab_metavalue %x %y $mytoplevel 0" - $mytoplevel.resultstext tag bind "intro_link$i" \ - "::dialog_search::open_file %x %y $mytoplevel dir 0" - $mytoplevel.resultstext tag bind "intro_link$i" \ - "$mytoplevel.statusbar configure -text \"\"" - $mytoplevel.resultstext tag configure "metavalue$i" -font \ - "$searchfont 12" - $mytoplevel.resultstext tag configure "intro_link$i" -font \ - "$searchfont 12" - $mytoplevel.resultstext tag bind "dir_title$i" \ - "::dialog_search::open_file %x %y $mytoplevel dir 0" - $mytoplevel.resultstext tag bind "dir_title$i" \ - "$mytoplevel.resultstext configure -cursor xterm; \ - $mytoplevel.statusbar configure -text \"\"" - $mytoplevel.resultstext tag configure "dir_title$i" \ - -font "$searchfont 12" -underline on -spacing1 6 - } - # this next tag configure comes after the metavalue stuff above so - # that it has a higher priority (these are the keywords in the search - # results) - $mytoplevel.resultstext tag configure keywords -font "$searchfont 10" - $mytoplevel.resultstext tag configure homepage_file -font "$searchfont 12" - $mytoplevel.resultstext tag bind homepage_file "::dialog_search::open_file \ - %x %y $mytoplevel file 1" - $mytoplevel.resultstext tag bind homepage_file "::dialog_search::open_file \ - %x %y $mytoplevel file 0" - $mytoplevel.resultstext tag bind homepage_file "$mytoplevel.statusbar configure \ - -text \"\"" - $mytoplevel.resultstext tag bind title "::dialog_search::open_file %x %y \ - $mytoplevel file 1" - $mytoplevel.resultstext tag bind title "::dialog_search::open_file %x %y \ - $mytoplevel file 0" - $mytoplevel.resultstext tag bind dir_title "::dialog_search::open_file %x %y \ - $mytoplevel dir 0" - $mytoplevel.resultstext tag bind dir_title "$mytoplevel.resultstext configure \ - -cursor xterm; $mytoplevel.statusbar configure -text \"\"" - $mytoplevel.resultstext tag bind help_icon "::dialog_search::get_info %x %y \ - $mytoplevel" - $mytoplevel.resultstext tag bind help_icon "$mytoplevel.resultstext configure \ - -cursor hand2; $mytoplevel.statusbar configure -text \"Get info on this object's\ - libdir\"" - $mytoplevel.resultstext tag bind help_icon "$mytoplevel.resultstext configure \ - -cursor xterm; $mytoplevel.statusbar configure -text \"\"" - $mytoplevel.resultstext tag bind folder_icon "::dialog_search::open_file %x %y \ - $mytoplevel dir_in_fm 1" - $mytoplevel.resultstext tag bind folder_icon "::dialog_search::open_file %x %y \ - $mytoplevel dir_in_fm 0" - $mytoplevel.resultstext tag bind folder_icon "$mytoplevel.resultstext configure \ - -cursor xterm; $mytoplevel.statusbar configure -text \"\"" - $mytoplevel.resultstext tag bind clickable_dir "::dialog_search::click_dir \ - $mytoplevel.resultstext %x %y" - # another workaround: we can't just do a mouseover statusbar update with clickable_dir - # since it wouldn't register an event when moving the mouse from one dir to an - # adjacent dir. So we have the intro_link$i hack above PLUS a separate binding for navbar - # links (which are not adjacent) - $mytoplevel.resultstext tag bind navbar_dir "::dialog_search::open_file %x %y \ - $mytoplevel dir 0" - $mytoplevel.resultstext tag bind navbar_dir "$mytoplevel.statusbar configure \ - -text \"\"" - - # search window widget bindings - bind $mytoplevel <$::modifier-equal> "::dialog_search::font_size $mytoplevel.resultstext 1" - bind $mytoplevel <$::modifier-plus> "::dialog_search::font_size $mytoplevel.resultstext 1" - bind $mytoplevel <$::modifier-minus> "::dialog_search::font_size $mytoplevel.resultstext 0" - bind $mytoplevel.searchtextentry "$mytoplevel.searchbutton invoke" - bind $mytoplevel.searchtextentry <$::modifier-Key-BackSpace> \ - "::dialog_search::ctrl_bksp $mytoplevel.searchtextentry" - bind $mytoplevel.searchtextentry <$::modifier-Key-a> \ - "$mytoplevel.searchtextentry selection range 0 end; break" - bind $mytoplevel.f.genrebox <> "::dialog_search::filter_results \ - $mytoplevel.f.genrebox $mytoplevel.resultstext" - bind $mytoplevel.f.matchall_check "$mytoplevel.searchbutton invoke" - bind $mytoplevel.f.matchwords_check "$mytoplevel.searchbutton invoke" - bind $mytoplevel.advancedlabel "$mytoplevel.advancedlabel configure \ - -cursor hand2; $mytoplevel.statusbar configure -text \"Advanced search options\"" - bind $mytoplevel.advancedlabel "$mytoplevel.advancedlabel configure \ - -cursor xterm; $mytoplevel.statusbar configure -text \"\"" - bind $mytoplevel.advancedlabel \ - {menu_doc_open doc/5.reference all_about_finding_objects.pd} - ::pd_bindings::dialog_bindings $mytoplevel "search" - - # Add state and set focus - $mytoplevel.searchtextentry insert 0 "Enter search terms" - $mytoplevel.searchtextentry selection range 0 end - # go ahead and set tags for the default genre - filter_results $mytoplevel.f.genrebox $mytoplevel.resultstext - focus $mytoplevel.searchtextentry - ::dialog_search::intro $mytoplevel.resultstext - set ::dialog_search::matchall 1 - set ::dialog_search::matchwords 1 -} - # create the menu item on load -set mymenu .menubar.help -set inserthere [$mymenu index [_ "Report a bug"]] -$mymenu insert $inserthere separator -$mymenu insert $inserthere command -label [_ "Search"] \ - -command {::dialog_search::open_search_dialog .search} + set mymenu .menubar.help + set inserthere [$mymenu index [_ "Report a bug"]] + $mymenu insert $inserthere separator + $mymenu insert $inserthere command -label [_ "Browser2.0"] \ + -command {::dialog_helpbrowser2::open_helpbrowser .helpbrowser2} + bind all <$::modifier-Key-h> \ + {::dialog_helpbrowser2::open_helpbrowser .helpbrowser2} # Folder icon "folder16" # from kde klassic icons (license says GPL/LGPL) -image create photo ::dialog_search::folder -data { +image create photo ::dialog_helpbrowser2::folder -data { R0lGODlhEAAQAIMAAPwCBNSeBJxmBPz+nMzOZPz+zPzSBPz2nPzqnAAAAAAA AAAAAAAAAAAAAAAAAAAAACH5BAEAAAAALAAAAAAQABAAAARFEMhJ6wwYC3uH 98FmBURpElkmBUXrvsVgbOxw3F8+A+zt/7ddDwgUFohFWgGB9BmZzcMTASUK @@ -1026,7 +1097,7 @@ image create photo ::dialog_search::folder -data { # Info icon "acthelp16" # from kde slick icons (license says GPL/LGPL) -image create photo ::dialog_search::help -data { +image create photo ::dialog_helpbrowser2::help -data { R0lGODlhEAAQAIYAAPwCBCSK7ASO9Bye9GTG/ITO/JzW/HTC/FS6/Bya/ARe 3FS+/Jzi/LTm/Mzu/LTi/KTa/HzC/GSy/AR+/AQudGy+/MTq/Nzy/OT2/Lzm /KTi/ITK/Hy+/Fym/CSG/ARSzAQmZCyW9OTy/Pz+/Oz2/Dye/BR2/ARm/AQ2 -- cgit v1.2.1