[tw5] Re: How to highlight targetStrings within a macro with splitregex/join, i.e., treat the macro as a string?

2020-07-21 Thread 'steve' via TiddlyWiki

HI Eric:

>From your latest email I've incorporated the number of times targetString 
was matched and the div for the showOutput.
I've also echoed the input parameters to formatTid.highlightText and added 
a "pane" format for the target string.

Thanks to your help it keeps getting better and better.
Here is a screen shot of the results.

Thanks again
Steve




\define formatTid.highlightText(source:"MainMenu" targetString:"Handler" 
highlightColor:"blue" 
highlightStyle:"background-color:khaki;color:#656565;font-size:8.5pt;font-weight:bold;border-radius:
 
2px;border-style:solid;border-color:gray;border-width:1px;")

<$set name="outputText" filter=
"[{$source$}splitregexp[$targetString$]join[@@$highlightStyle$$targetString$@@]]"
 
select="0">


|''For source'': @@color:navy;font-size:8pt;font-weight:bold;$source$@@; ''
targetString'': @@color:navy;font-size:8pt;font-weight:bold;$targetString$@@
; ''found'' @@color:navy;font-size:8pt;font-weight:bold;<$text text={{{ [{
$source$}splitregexp[$targetString$]count[]subtract[1]] }}} /> match(es).@@|



<>


\end
\define showOutput()
\rules only styleinline
$(outputText)$
\end
\define formatTid.highlightText.ui()


---


''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
<$vars targetString={{$:/temp/highlight/targetString}}>


''Select Source (tiddler)'' 
@@color:navy;font-variant:super;font-weight:bold;(<$count filter="[!is[
system]search:texthas[code-library]]"/> found)@@ <$select 
tiddler="$:/temp/highlight/source" default="blurg">
<$list 
filter="[!is[system]search:texthas[code-library]sort[]]">>><$text text=<>/>



<$reveal text={{$:/temp/highlight/source}}  type="nomatch" default="">
<$macrocall $name="formatTid.highlightText" 
source={{$:/temp/highlight/source}} targetString=<>/>



---
\end
<>


-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/43d692c8-88ae-4c77-acc7-a5e5ecba53d4o%40googlegroups.com.


[tw5] Re: How to highlight targetStrings within a macro with splitregex/join, i.e., treat the macro as a string?

2020-07-21 Thread 'steve' via TiddlyWiki
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">


|''targetString is highlighted in @@color:$highlightColor$; 
$highlightColor$@@''|
|@@white-space:pre-wrap;font-family:monospace;<>@@|

\end
\define showOutput()
\rules only styleinline
$(outputText)$
\end


''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
<$vars targetString={{$:/temp/highlight/targetString}}>

''Select Source Tid'' (if any) <$select tiddler="$:/temp/highlight/source" 
default="blurg">
<$list filter=
"[!is[system]search:texthas[code-library]sort[]]">>><$text text=<>/>


<$reveal text={{$:/temp/highlight/source}}  type="nomatch" default="">
<$macrocall $name="formatTid.highlightText" source={{$:/temp/highlight/
source}} targetString=<>/>




-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f374731b-dfd1-4a89-b15a-82ede97882e8o%40googlegroups.com.


[tw5] Re: How to highlight targetStrings within a macro with splitregex/join, i.e., treat the macro as a string?

2020-07-20 Thread 'steve' via TiddlyWiki

Update:

This time I tried a macro with a filter that used goFish in a filter. See 
below.
Nothing was listed in the outputText. 
Tomorrow I'll look at the literal output text.



\define goFish()

!!! This example has five goFish

!!! This goFish is in a macro.
<$list filter="[search:text[goFish]]" variable="match">

<>



\end
<>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/4b6a0f3c-81e9-4e60-8ed5-02cf23e11127o%40googlegroups.com.


[tw5] Re: How to highlight targetStrings within a macro with splitregex/join, i.e., treat the macro as a string?

2020-07-20 Thread 'steve' via TiddlyWiki
Eric:

Very tricky indeed but you made it look simple! 

It worked - yay! I am trying some more complex examples including 
embedded macro calls and will report back.

Thanks!

Steve

On Monday, July 20, 2020 at 6:13:07 PM UTC-4, Eric Shulman wrote:
>
> On Monday, July 20, 2020 at 1:55:57 PM UTC-7, steve wrote:
>>
>> I am working on a macro to highlight target strings within the text field 
>> of a tiddler.  
>> The use case is to make it easier to for me see where the targetStrings 
>> are (if any).   
>>
>  
>
>> My question is how to highlight the targetString in the macro (ie. 
>> treating 
>> the macro as a string) as opposed to (apparently) executing the macro 
>> and highlighting the targetString in the output.
>>
>>
> There's nothing wrong with your filter and regexp usage.
>
> To see the literal output text, I used the <$text> widget in the table, 
> like this:
> \define formatTid.highlightText(inputText targetString)
> <$set name="outputText" filter="[[$inputText$]] 
>  +[splitregexp[\b$targetString$\b]join[@@color:blue;$targetString$@@]]" 
> select="0">
>
> | ''outputText''|<$text text=<>/>|
> \end
> <$macrocall $name="formatTid.highlightText" 
> inputText={{highlightTest.sentence!!text}} targetString="goFish"/>
>
> The result of the above (using your example input) is:
> outputText \define @@color:blue;goFish@@() !!! This example has three 
> instances of @@color:blue;goFish@@. \end <<@@color:blue;goFish@@>>
>
> As you can see, your regexp filter DID find and replace all the 
> targetString instances by wrapping them with "@@color:blue;...@@" as you 
> intended.  Of course, that doesn't produce the output you want, which is to 
> see the full input text *with the blue highlighting*.
>
> The problem with using just <> in the table stems from the way 
> the TWCore parser processes and renders the "outputText" value.
>
> 1) anything starting with "\define" or "\end" is part of a macro 
> definition, and the TWCore doesn't *render* those as output.
>
> 2) anything from "<<" through ">>" is a macro invocation, and if the macro 
> isn't defined in the current context, then it produces no output.
>
> Thus, only the normal wikitext content in your example is displayed as 
> output and the macro definition and macro invocation are not shown.
>
> Fortunately, I did find a way to get something closer to what you want.  
> Try this:
> \define formatTid.highlightText(inputText targetString)
> <$set name="outputText" filter="[[$inputText$]] 
>  +[splitregexp[\b$targetString$\b]join[@@color:blue;$targetString$@@]]" 
> select="0">
>
> | ''outputText''|@@white-space:pre;<>@@|
> \end
>
> \define showOutput()
> \rules only styleinline
> $(outputText)$
> \end
>
> <$macrocall $name="formatTid.highlightText" inputText={{highlightTest.
> sentence!!text}} targetString="goFish"/>
>
> * The @@white-space:pre;...@@ in the table forces whitespace to be 
> rendered as-is (the default rendering collapses all whitespace)
> * The showOutput() macro uses the "\rules" pragma to disable all parsing 
> except for "styleinline" (the "@@" syntax)
>
> The result of the above (using your example input) is:
> outputText \define goFish() !!! This example has three instances of goFish. 
> \end <>
>
> Which is, I think, very close to what you intended.
>
> Tricky stuff, eh?
>
> Let me know how it goes...
>
> enjoy,
> -e
>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/f175df20-c265-4bff-a0da-cc4224433399o%40googlegroups.com.


[tw5] Re: How to highlight targetStrings within a macro with splitregex/join, i.e., treat the macro as a string?

2020-07-20 Thread 'steve' via TiddlyWiki
Hi Tony, Saq:

More about my use case ...

When I look at macro (code) in the editor it is very easy for me to 
overlook variable or macro names that I want to change
and so I fail to update all of them.  The purpose of the 
formatTid.highlightText macro is to create a highlighted copy of the macro 
code
with the css @@color:blue; targetString@@ imbedded around each instance of 
the targetString.

Tony: I am working through your suggestions -- thanks.
Saq: I tried dynannotate and it does what I want with regular text -- 
thanks!  I could not get it to work with text within macro code.

Is there a why to treat/convert/escape (?) macro code (ie anything between 
\define and \end as a string without executing/running it?

Thanks Again
Steve

On Monday, July 20, 2020 at 5:33:06 PM UTC-4, Saq Imtiaz wrote:
>
> @steve just in case you haven't seen it, there's a plugin that does 
> something very similar:
>
>
> https://tiddlywiki.com/prerelease/#%24%3A%2Fplugins%2Ftiddlywiki%2Fdynannotate
>
> Check out the examples tab in the plugin tiddler.
>
>

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/81e6c48f-23fc-4740-a6aa-a1a49a65ea94o%40googlegroups.com.


[tw5] How to highlight targetStrings within a macro with splitregex/join, i.e., treat the macro as a string?

2020-07-20 Thread 'steve' via TiddlyWiki
Hello:

I am working on a macro to highlight target strings within the text field 
of a tiddler.  
The use case is to make it easier to for me see where the targetStrings are 
(if any).   

My question is how to highlight the targetString in the macro (ie. treating 
the macro as a string) as opposed to (apparently) executing the macro 
and highlighting the targetString in the output.

!!! Here is the macro
```
\define formatTid.highlightText(inputText targetString)

<$set name="outputText" filter="[[$inputText$]] 
+[splitregexp[\b$targetString$\b]join[@@color:blue;$targetString$@@]]" 
select="0">

| ''outputText''|<> |

\end
<$macrocall $name="formatTid.highlightText" 
inputText={{highlightTest.sentence!!text}} targetString="goFish"/>
```

The macro works as expected (goFish is highlighted in blue) when the text 
field contains

```
This goFish is in a sentence.
```

The macro works partially (i.e., goFish is highlighted only for the 
comment).

```
\define goFish()

!!! This example has three instances of goFish.

\end
<>
```

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8a9ea408-11fb-4e2e-995b-f3e3f04a288ao%40googlegroups.com.


[tw5] Re: where are the checkbox images used by the checkbox widget?

2020-02-27 Thread 'steve' via TiddlyWiki
Hi Eric

I'll look into using  instead of images in the 
toggle-in-field macro suggested by Mat from another thread about using 
checkboxes to add/delete items in a field.

Thanks
Steve W

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/eaa8683c-998e-4c3d-bb56-067099dabfc8%40googlegroups.com.


[tw5] where are the checkbox images used by the checkbox widget?

2020-02-27 Thread 'steve' via TiddlyWiki
Hi

I looked in core (specifically in $:/core/images/) for the checkbox images 
used by the checkbox widget (see below) but could not find an image with 
checkbox in the title. Where should I be looking for these?


Thanks
Steve W

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/175e6cb1-ba9a-40ba-bd5a-0319b4b9766c%40googlegroups.com.


[tw5] Re: request extension to checkbox widget to support adding/deleting multiple keywords per field

2020-02-26 Thread 'steve' via TiddlyWiki
bimlas: 

I'll take a look - Thanks

Steve W

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/0964caf4-460a-414e-9ac1-8be8717891b1%40googlegroups.com.


[tw5] Re: request extension to checkbox widget to support adding/deleting multiple keywords per field

2020-02-25 Thread 'steve' via TiddlyWiki
Hi

Suggestion for a "list mode" for checkbox widget.



 * shows checkbox as checked if field contains the tag, unchecked otherwise;
 * appends tag to field when box is checked;
 * removes tag from field when box is unchecked;
 * does NOT default to text if field not provided;
 * filter field content using current regex or search filter operators;
 * alternatively filter content using tag:fieldName[tag] construct (default 
is to used the tag field);

Meanwhile I'll read more about (
https://github.com/Jermolene/TiddlyWiki5/issues/1957 

).

Steve W

-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/eb873083-496c-455c-ae38-6a8b493d76ae%40googlegroups.com.


[tw5] Re: request extension to checkbox widget to support adding/deleting multiple keywords per field

2020-02-25 Thread 'steve' via TiddlyWiki

Hi Again

Mark S: I am treating the field as a list and using listops to add/remove 
keywords as you noted in your response. Also I posted a tiddler-level view 
(ie. edit view) above.

Mat: The toggle-in-field capability you suggested appears to provide the 
functionality I was looking for as does the feature cited by Mat 
(https://github.com/Jermolene/TiddlyWiki5/issues/1957).

TonyM: My current solution meets my requirement of adding/removing keywords 
via checkbox, the problem is that I have to use tags with a state tiddler 
in order to do it.  Rather than changing the "tag mode" of checkbox I was 
thinking more along the lines of augmenting the "field mode".

PMario: I am not seeing the problem with there is a problem with 
checkactions and uncheckactions in my implementation.

Thanks to all that responded.

Steve W


-- 
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/4b69a59f-cad8-4076-ada8-3deb03ef6cc3%40googlegroups.com.