From 0dcc5ea601fc4d644551229c33cd376d6a260d57 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Wed, 12 Jan 2011 23:59:52 +0000 Subject: search for beginnings of words and filter output to use ASCII art Pd patch notation svn path=/trunk/scripts/guiplugins/search-plugin/; revision=14732 --- search-plugin.tcl | 18 ++++++++++++------ 1 file 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 -- cgit v1.2.1