mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-10 16:10:02 +00:00
WIP improve dumpvariables macro, add search-variables macro
This commit is contained in:
parent
d5e3c2c26c
commit
409345b126
@ -3,9 +3,10 @@ tags: $:/tags/Macro
|
|||||||
|
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
|
|
||||||
\procedure dumpvariables()
|
<!-- =================== -->
|
||||||
|
\procedure dumpvariables(subfilter:"[variables[]]")
|
||||||
<ul>
|
<ul>
|
||||||
<$list filter="[variables[]]" variable="varname">
|
<$list filter="[variables[]] :and[subfilter<subfilter>]" variable="varname">
|
||||||
<li>
|
<li>
|
||||||
<strong><code><$text text=<<varname>>/></code></strong>:<br/>
|
<strong><code><$text text=<<varname>>/></code></strong>:<br/>
|
||||||
<$codeblock code={{{ [<varname>getvariable[]] }}}/>
|
<$codeblock code={{{ [<varname>getvariable[]] }}}/>
|
||||||
@ -14,38 +15,45 @@ tags: $:/tags/Macro
|
|||||||
</ul>
|
</ul>
|
||||||
\end
|
\end
|
||||||
|
|
||||||
|
<!-- =================== -->
|
||||||
|
\procedure search-variables(subfilter:"[<currentTiddler>]")
|
||||||
|
|
||||||
|
\procedure search() $:/temp/search/dump
|
||||||
|
\procedure sub-search() $:/temp/search/sub-dump
|
||||||
|
\procedure state() $:/state/search/var/
|
||||||
|
|
||||||
\procedure toggleState()
|
\procedure toggleState()
|
||||||
<$action-setfield $tiddler=<<getVarState>> text={{{ [<getVarState>get[text]] +[toggle[yes],[no]] }}}/>
|
<$action-setfield $tiddler=<<getVarState>> text={{{ [<getVarState>get[text]] +[toggle[yes],[no]] }}}/>
|
||||||
\end
|
\end toggleState
|
||||||
|
|
||||||
\procedure toggleInfoState()
|
\procedure toggleInfoState()
|
||||||
<$action-setfield $tiddler=<<getToggleInfoState>> text={{{ [<getToggleInfoState>get[text]] +[toggle[yes],[no]] }}}/>
|
<$action-setfield $tiddler=<<getToggleInfoState>> text={{{ [<getToggleInfoState>get[text]] +[toggle[yes],[no]] }}}/>
|
||||||
<$action-setfield $tiddler=<<getSubSearch>> text={{{ [<getSubSearchText>!is[blank]then<getSubSearchText>] :else[<varname>] }}} />
|
<$action-setfield $tiddler=<<getSubSearch>> text={{{ [<getSubSearchText>!is[blank]then<getSubSearchText>] :else[<varname>] }}} />
|
||||||
\end
|
\end toggleInfoState
|
||||||
|
|
||||||
\procedure clearStatesButton()
|
\procedure clearStatesButton()
|
||||||
<$button class="tc-btn-invisible tc-tiny-gap-left">
|
<$button class="tc-btn-invisible tc-tiny-gap-left">
|
||||||
<$action-deletetiddler $filter="[prefix<state>] [prefix[$:/temp]]"/>
|
<$action-deletetiddler $filter="[prefix<state>] [prefix[$:/temp]]"/>
|
||||||
{{$:/core/images/fold-all-button}}
|
{{$:/core/images/fold-all-button}}
|
||||||
</$button>
|
</$button>
|
||||||
\end
|
\end clearStatesButton
|
||||||
|
|
||||||
\procedure clearSearchButton()
|
\procedure clearSearchButton()
|
||||||
<$button class="tc-btn-invisible tc-tiny-gap-left">
|
<$button class="tc-btn-invisible tc-tiny-gap-left">
|
||||||
<$action-deletetiddler $tiddler=<<search>>/>
|
<$action-deletetiddler $tiddler=<<search>>/>
|
||||||
{{$:/core/images/close-button}}
|
{{$:/core/images/close-button}}
|
||||||
</$button>
|
</$button>
|
||||||
\end
|
\end clearSearchButton
|
||||||
|
|
||||||
\procedure expandAllStatesButton()
|
\procedure expandAllStatesButton()
|
||||||
<$button class="tc-btn-invisible tc-tiny-gap-left">
|
<$button class="tc-btn-invisible tc-tiny-gap-left">
|
||||||
<$list filter="[variables[]] +[search::some<getSearchText>]" variable="varname">
|
<$action-setfield $tiddler=<<state>> text={{{ [<getToggleInfoState>get[text]] +[toggle[yes],[no]] }}}/>
|
||||||
|
<$list filter="[variables[]] +[search::some<getSearchText>] :filter[subfilter<subfilter>]" variable="varname">
|
||||||
<$action-setfield $tiddler=<<getVarState>> text="yes"/>
|
<$action-setfield $tiddler=<<getVarState>> text="yes"/>
|
||||||
</$list>
|
</$list>
|
||||||
{{$:/core/images/unfold-all-button}}
|
{{$:/core/images/unfold-all-button}}
|
||||||
</$button>
|
</$button>
|
||||||
\end
|
\end expandAllStatesButton
|
||||||
|
|
||||||
\procedure info()
|
\procedure info()
|
||||||
<!-- <$let xx={{{ "\define" [<varname>] +[join[ ]] }}}> -->
|
<!-- <$let xx={{{ "\define" [<varname>] +[join[ ]] }}}> -->
|
||||||
@ -61,15 +69,8 @@ tags: $:/tags/Macro
|
|||||||
<$link class="tc-small-gap-left"/><br>
|
<$link class="tc-small-gap-left"/><br>
|
||||||
</$list>
|
</$list>
|
||||||
</div>
|
</div>
|
||||||
\end
|
\end info
|
||||||
|
|
||||||
<!-- =================== -->
|
|
||||||
|
|
||||||
<!-- =================== -->
|
|
||||||
\procedure filtered-dumpvariables(subfilter)
|
|
||||||
\procedure search() :/temp/search/dump
|
|
||||||
\procedure sub-search() :/temp/search/sub-dump
|
|
||||||
\procedure state() :/state/search/var/
|
|
||||||
|
|
||||||
\function getSearchText() [<search>get[text]]
|
\function getSearchText() [<search>get[text]]
|
||||||
|
|
||||||
@ -79,12 +80,16 @@ tags: $:/tags/Macro
|
|||||||
\function getVarState() [<state>addsuffix<varname>] [<qualify>] +[join[]]
|
\function getVarState() [<state>addsuffix<varname>] [<qualify>] +[join[]]
|
||||||
\function getToggleInfoState() [<state>addsuffix<varname>]
|
\function getToggleInfoState() [<state>addsuffix<varname>]
|
||||||
|
|
||||||
<$text text="Filtered Variable Dump -- "/><<transclusion>>
|
<$text text="Search Variables - "/><%if [<thisTiddler>!match[$:/AdvancedSearch]]%><code><<subfilter>></code><%endif%>
|
||||||
|
<$edit-text tiddler=<<search>> tag=input/> <<clearSearchButton>>
|
||||||
|
<% if [<state>get[text]match[yes]] %>
|
||||||
|
<<clearStatesButton>>
|
||||||
|
<% else %>
|
||||||
|
<<expandAllStatesButton>>
|
||||||
|
<% endif %>
|
||||||
|
|
||||||
<$edit-text tiddler=<<search>> tag=input/> <<clearSearchButton>> <<expandAllStatesButton>> <<clearStatesButton>>
|
<$list filter="[variables[]] +[search::some<getSearchText>] :filter[subfilter<subfilter>]" variable="varname">
|
||||||
|
<div class="tc-var-item">
|
||||||
<$list filter="[variables[]] +[search::some<getSearchText>]" variable="varname">
|
|
||||||
<div>
|
|
||||||
<$button actions=<<toggleState>> class="tc-small-gap-left tc-btn-invisible">
|
<$button actions=<<toggleState>> class="tc-small-gap-left tc-btn-invisible">
|
||||||
<% if [<getVarState>get[text]match[yes]] %>
|
<% if [<getVarState>get[text]match[yes]] %>
|
||||||
{{$:/core/images/down-arrow}}
|
{{$:/core/images/down-arrow}}
|
||||||
@ -92,7 +97,7 @@ tags: $:/tags/Macro
|
|||||||
{{$:/core/images/right-arrow}}
|
{{$:/core/images/right-arrow}}
|
||||||
<% endif %>
|
<% endif %>
|
||||||
<strong class="tc-tiny-gap-right"><code><$text text=<<varname>>/></code></strong>
|
<strong class="tc-tiny-gap-right"><code><$text text=<<varname>>/></code></strong>
|
||||||
<$text text={{{ [<varname>getvariable[]length[]] "Chars" +[join[ ]] }}}/>
|
<$text text={{{ "#" [<varname>getvariable[]length[]] +[join[ ]] }}}/>
|
||||||
</$button>
|
</$button>
|
||||||
|
|
||||||
<% if [<getVarState>get[text]match[yes]] %>
|
<% if [<getVarState>get[text]match[yes]] %>
|
||||||
|
@ -0,0 +1,8 @@
|
|||||||
|
caption: Variables
|
||||||
|
created: 20240215233810357
|
||||||
|
modified: 20240216005108246
|
||||||
|
tags: $:/tags/AdvancedSearch
|
||||||
|
title: $:/core/ui/AdvancedSearch/Variables
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
<<search-variables>>
|
@ -1,9 +1,9 @@
|
|||||||
|
caption: dumpvariables
|
||||||
created: 20140908104107181
|
created: 20140908104107181
|
||||||
modified: 20150221151454000
|
modified: 20240216150310916
|
||||||
tags: Macros [[Core Macros]]
|
tags: Macros [[Core Macros]]
|
||||||
title: dumpvariables Macro
|
title: dumpvariables Macro
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
caption: dumpvariables
|
|
||||||
|
|
||||||
The <<.def dumpvariables>> [[macro|Macros]] returns a table showing the values of all [[variables|Variables]] and [[macros|Macros]] that exist at that position in the [[widget tree|Widgets]].
|
The <<.def dumpvariables>> [[macro|Macros]] returns a table showing the values of all [[variables|Variables]] and [[macros|Macros]] that exist at that position in the [[widget tree|Widgets]].
|
||||||
|
|
||||||
@ -13,6 +13,7 @@ Placeholders are replaced with values in the normal way, but using the default v
|
|||||||
|
|
||||||
!! Parameters
|
!! Parameters
|
||||||
|
|
||||||
(none)
|
; subfilter
|
||||||
|
: This parameter limits the number of variables that are listed
|
||||||
|
|
||||||
<<.macro-examples "dumpvariables">>
|
!!! <<.macro-examples "dumpvariables">>
|
||||||
|
@ -1,14 +1,20 @@
|
|||||||
created: 20150221151358000
|
created: 20150221151358000
|
||||||
modified: 20150221151415000
|
modified: 20240216150546249
|
||||||
tags: [[dumpvariables Macro]] [[Macro Examples]]
|
tags: [[dumpvariables Macro]] [[Macro Examples]]
|
||||||
title: dumpvariables Macro (Examples)
|
title: dumpvariables Macro (Examples)
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
<$macrocall $name=".example" n="1"
|
<$macrocall $name=".example" n="1"
|
||||||
eg="""<$set name="EXAMPLE" value="123.$(EXAMPLE2)$.789">
|
eg="""<$let EXAMPLE="123" >
|
||||||
<$set name="EXAMPLE2" value="456">
|
<<dumpvariables subfilter:"EXAMPLE dumpvariables">>
|
||||||
|
</$let>"""/>
|
||||||
|
|
||||||
|
<$macrocall $name=".example" n="2"
|
||||||
|
eg="""<<dumpvariables subfilter:"[prefix[.a]]">>"""/>
|
||||||
|
|
||||||
|
The following list will be very long. It shows all variables known within this tiddler. Using the macro in a different context. Eg: the sidebar, variables will have different values.
|
||||||
|
|
||||||
|
<$macrocall $name=".example" n="3"
|
||||||
|
eg="""<<dumpvariables>>"""/>
|
||||||
|
|
||||||
<<dumpvariables>>
|
|
||||||
|
|
||||||
</$set>
|
|
||||||
</$set>"""/>
|
|
||||||
|
7
editions/tw5.com/tiddlers/test-search-variables.tid
Normal file
7
editions/tw5.com/tiddlers/test-search-variables.tid
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
created: 20240216004004135
|
||||||
|
modified: 20240216010811339
|
||||||
|
tags:
|
||||||
|
title: test-search-variables
|
||||||
|
type: text/vnd.tiddlywiki
|
||||||
|
|
||||||
|
<<search-variables subfilter:"[search::some[attr this]]">>
|
Loading…
x
Reference in New Issue
Block a user