Eric:
I made some additional tweaks to your solution to:
* narrow selection list to list of tiddlers that actually contain the
targetString
* provide a GO button so that macro does not have to run for every
keystroke in the edit box
* added a reveal so that macro is run only if a source tiddler was selected
* added parameter to set the highlightColor
Tony:
* I'll look into codemirror
* there did not appear to be a link for your playground wiki
Thanks to all that responded!
Steve
Enter code here...\define formatTid.highlightText(source:"MainMenu"
targetString:"Handler" highlightColor:"blue")
<$set name="outputText" filter=
"[{$source$}splitregexp[$targetString$]join[@@color:$highlightColor$;$targetString$@@]]"
select="0">
<!-- Future Ideas
* display number of matches
* use CSS for highlighting not just color
-->
|''targetString is highlighted in @@color:$highlightColor$;
$highlightColor$@@''|
|@@white-space:pre-wrap;font-family:monospace;<<showOutput>>@@|
\end
\define showOutput()
\rules only styleinline
$(outputText)$
\end
<!-- 1. Type string into entryBuffer
2. press GO to:
* copy string from entryBuffer to targetString (avoids
responding to each keystroke)
* initialize source to ""
3. list tiddlers that contain targetString (if any)
4. select tiddler to be highlighted
-->
''Enter targetString and press GO'' <$edit-text tiddler=
"$:/temp/highlight/entryBuffer" tag="input" default="" placeholder="enter
text to highlight" />
<$button><$action-setfield $tiddler="$:/temp/highlight/targetString" $value
={{$:/temp/highlight/entryBuffer}}/><$action-setfield $tiddler=
"$:/temp/highlight/source" $value=""/>GO</$button>
<$vars targetString={{$:/temp/highlight/targetString}}><br>
''Select Source Tid'' (if any) <$select tiddler="$:/temp/highlight/source"
default="blurg">
<$list filter=
"[!is[system]search:text<targetString>has[code-library]sort[]]"><option
value=<<currentTiddler>>><$text text=<<currentTiddler>>/></option></$list>
</$select><br>
<$reveal text={{$:/temp/highlight/source}} type="nomatch" default="">
<$macrocall $name="formatTid.highlightText" source={{$:/temp/highlight/
source}} targetString=<<targetString>>/>
</$reveal>
</$vars>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/f374731b-dfd1-4a89-b15a-82ede97882e8o%40googlegroups.com.