aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-01-12 23:59:52 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2011-01-12 23:59:52 +0000
commit0dcc5ea601fc4d644551229c33cd376d6a260d57 (patch)
tree9532c593f97d0703318eac3f2268cb07fbda4bcb
parentec3bf2c5ff4d25ab2aa31dc13812962a89881189 (diff)
search for beginnings of words and filter output to use ASCII art Pd patch notation
svn path=/trunk/scripts/guiplugins/search-plugin/; revision=14732
-rw-r--r--search-plugin.tcl18
1 files changed, 12 insertions, 6 deletions
diff --git a/search-plugin.tcl b/search-plugin.tcl
index 79dea3a..f45b566 100644
--- a/search-plugin.tcl
+++ b/search-plugin.tcl
@@ -12,10 +12,6 @@ namespace eval ::dialog_search:: {
variable basedir_list {}
}
-# TODO filter out x,y numbers and #X, highlight obj/text/array/etc
-# TODO show the busy state somehow, grey out entry?
-# TODO add implied '^' to searches that don't contain regexp [a-zA-Z0-9 _-]
-
# find_doc_files
# basedir - the directory to start looking in
proc ::dialog_search::find_doc_files { basedir } {
@@ -108,8 +104,18 @@ proc ::dialog_search::searchfile {searchtext file_contents widget filename based
variable basedir_list
set n 0
foreach line $file_contents {
- if {[regexp -nocase -- $searchtext $line]} {
- set formatted_line [regsub {^#X (\S+) [0-9]+ [0-9]+} $line {〈\1〉}]
+ # TODO this could be optimized so that the lines are added to
+ # a var, then the regsubs are run on the whole text, then its
+ # inserted into the widget
+ if {[regexp -nocase -- "\[^a-zA-Z\]$searchtext" $line]} {
+ set line [regsub { \\} $line {}]
+ set line [regsub {\\} $line {}]
+ set line [regsub {^#X text [0-9]+ [0-9]+ (.*?);*} $line {\1}]
+ set line [regsub {^#X obj [0-9]+ [0-9]+ (.*?);*} $line {[ \1]}]
+ set line [regsub {^#X msg [0-9]+ [0-9]+ (.*?);*} $line {⃒ \1〈}]
+ set line [regsub {^#X (\S+) [0-9]+ [0-9]+(.*?);*} $line {〈\1〉\2}]
+ set formatted_line [regsub {^#N \S+ [0-9]+ [0-9]+ [0-9]+ [0-9]+ (.*?);} \
+ $line {[pd \1]}]
$widget insert end "$filename: $formatted_line"
lappend basedir_list $basedir
incr n