From 409345b1262e6f10648d54bdf5df5830b6fc4216 Mon Sep 17 00:00:00 2001 From: pmario Date: Fri, 16 Feb 2024 16:20:48 +0100 Subject: [PATCH] WIP improve dumpvariables macro, add search-variables macro --- core/wiki/macros/dumpvariables.tid | 49 ++++++++++--------- .../$__core_ui_AdvancedSearch_Variables.tid | 8 +++ .../tiddlers/macros/DumpVariablesMacro.tid | 9 ++-- .../macros/examples/dumpvariables.tid | 18 ++++--- .../tiddlers/test-search-variables.tid | 7 +++ 5 files changed, 59 insertions(+), 32 deletions(-) create mode 100644 editions/tw5.com/tiddlers/$__core_ui_AdvancedSearch_Variables.tid create mode 100644 editions/tw5.com/tiddlers/test-search-variables.tid diff --git a/core/wiki/macros/dumpvariables.tid b/core/wiki/macros/dumpvariables.tid index 72bca855a..5db23a919 100644 --- a/core/wiki/macros/dumpvariables.tid +++ b/core/wiki/macros/dumpvariables.tid @@ -3,9 +3,10 @@ tags: $:/tags/Macro \whitespace trim -\procedure dumpvariables() + +\procedure dumpvariables(subfilter:"[variables[]]") \end + +\procedure search-variables(subfilter:"[]") + +\procedure search() $:/temp/search/dump +\procedure sub-search() $:/temp/search/sub-dump +\procedure state() $:/state/search/var/ \procedure toggleState() <$action-setfield $tiddler=<> text={{{ [get[text]] +[toggle[yes],[no]] }}}/> -\end +\end toggleState \procedure toggleInfoState() <$action-setfield $tiddler=<> text={{{ [get[text]] +[toggle[yes],[no]] }}}/> <$action-setfield $tiddler=<> text={{{ [!is[blank]then] :else[] }}} /> -\end +\end toggleInfoState \procedure clearStatesButton() <$button class="tc-btn-invisible tc-tiny-gap-left"> <$action-deletetiddler $filter="[prefix] [prefix[$:/temp]]"/> {{$:/core/images/fold-all-button}} -\end +\end clearStatesButton \procedure clearSearchButton() <$button class="tc-btn-invisible tc-tiny-gap-left"> <$action-deletetiddler $tiddler=<>/> {{$:/core/images/close-button}} -\end +\end clearSearchButton \procedure expandAllStatesButton() <$button class="tc-btn-invisible tc-tiny-gap-left"> - <$list filter="[variables[]] +[search::some]" variable="varname"> + <$action-setfield $tiddler=<> text={{{ [get[text]] +[toggle[yes],[no]] }}}/> + <$list filter="[variables[]] +[search::some] :filter[subfilter]" variable="varname"> <$action-setfield $tiddler=<> text="yes"/> {{$:/core/images/unfold-all-button}} -\end +\end expandAllStatesButton \procedure info() @@ -61,15 +69,8 @@ tags: $:/tags/Macro <$link class="tc-small-gap-left"/>
-\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() [get[text]] @@ -79,12 +80,16 @@ tags: $:/tags/Macro \function getVarState() [addsuffix] [] +[join[]] \function getToggleInfoState() [addsuffix] -<$text text="Filtered Variable Dump -- "/><> +<$text text="Search Variables - "/><%if [!match[$:/AdvancedSearch]]%><><%endif%> +<$edit-text tiddler=<> tag=input/> <> +<% if [get[text]match[yes]] %> + <> +<% else %> + <> +<% endif %> -<$edit-text tiddler=<> tag=input/> <> <> <> - -<$list filter="[variables[]] +[search::some]" variable="varname"> -
+<$list filter="[variables[]] +[search::some] :filter[subfilter]" variable="varname"> +
<$button actions=<> class="tc-small-gap-left tc-btn-invisible"> <% if [get[text]match[yes]] %> {{$:/core/images/down-arrow}} @@ -92,7 +97,7 @@ tags: $:/tags/Macro {{$:/core/images/right-arrow}} <% endif %> <$text text=<>/> - <$text text={{{ [getvariable[]length[]] "Chars" +[join[ ]] }}}/> + <$text text={{{ "#" [getvariable[]length[]] +[join[ ]] }}}/> <% if [get[text]match[yes]] %> diff --git a/editions/tw5.com/tiddlers/$__core_ui_AdvancedSearch_Variables.tid b/editions/tw5.com/tiddlers/$__core_ui_AdvancedSearch_Variables.tid new file mode 100644 index 000000000..31956e4f8 --- /dev/null +++ b/editions/tw5.com/tiddlers/$__core_ui_AdvancedSearch_Variables.tid @@ -0,0 +1,8 @@ +caption: Variables +created: 20240215233810357 +modified: 20240216005108246 +tags: $:/tags/AdvancedSearch +title: $:/core/ui/AdvancedSearch/Variables +type: text/vnd.tiddlywiki + +<> \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/macros/DumpVariablesMacro.tid b/editions/tw5.com/tiddlers/macros/DumpVariablesMacro.tid index 563efffda..2a985827e 100644 --- a/editions/tw5.com/tiddlers/macros/DumpVariablesMacro.tid +++ b/editions/tw5.com/tiddlers/macros/DumpVariablesMacro.tid @@ -1,9 +1,9 @@ +caption: dumpvariables created: 20140908104107181 -modified: 20150221151454000 +modified: 20240216150310916 tags: Macros [[Core Macros]] title: dumpvariables Macro 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]]. @@ -13,6 +13,7 @@ Placeholders are replaced with values in the normal way, but using the default v !! Parameters -(none) +; subfilter +: This parameter limits the number of variables that are listed -<<.macro-examples "dumpvariables">> +!!! <<.macro-examples "dumpvariables">> diff --git a/editions/tw5.com/tiddlers/macros/examples/dumpvariables.tid b/editions/tw5.com/tiddlers/macros/examples/dumpvariables.tid index 2412368c2..e1338b223 100644 --- a/editions/tw5.com/tiddlers/macros/examples/dumpvariables.tid +++ b/editions/tw5.com/tiddlers/macros/examples/dumpvariables.tid @@ -1,14 +1,20 @@ created: 20150221151358000 -modified: 20150221151415000 +modified: 20240216150546249 tags: [[dumpvariables Macro]] [[Macro Examples]] title: dumpvariables Macro (Examples) type: text/vnd.tiddlywiki <$macrocall $name=".example" n="1" -eg="""<$set name="EXAMPLE" value="123.$(EXAMPLE2)$.789"> -<$set name="EXAMPLE2" value="456"> +eg="""<$let EXAMPLE="123" > +<> +"""/> + +<$macrocall $name=".example" n="2" +eg="""<>"""/> + +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="""<>"""/> -<> - -"""/> diff --git a/editions/tw5.com/tiddlers/test-search-variables.tid b/editions/tw5.com/tiddlers/test-search-variables.tid new file mode 100644 index 000000000..f3747e6a9 --- /dev/null +++ b/editions/tw5.com/tiddlers/test-search-variables.tid @@ -0,0 +1,7 @@ +created: 20240216004004135 +modified: 20240216010811339 +tags: +title: test-search-variables +type: text/vnd.tiddlywiki + +<> \ No newline at end of file