Hi Danielo,
there is no way to prevent your macro is refreshed on every keystroke
when it appears in a tiddler's preview window. Doesn't matter if you use
macro or widget. Your only chance to control the behaviour if you put it
somewhere else where the parent does not completely refresh all the
time. Then you can control the refreshes via the refresh function of
your widget by simply ignoring all the tiddlers in changedTiddlers that
are drafts (have a field "draft.of").
-Felix
On 07.04.2015 18:16, Danielo Rodríguez wrote:
> Hello everyone.
>
> I want to build a batch text processing tool on top of TW5. The first
> tool I have "implemented" is a column compare one. It is a macro that
> gets the text on two tiddlers and give you the unique values in one
> side of the comparison. The problem with using a macro is that it is
> evaluated on every keystroke, navigation event and so on. This is
> extremely slow and unefficent. Which kind of element should I use to
> make this more usable? A widget? if so, how? I would like to process
> just once and then show the result.
>
> This is what I have currently:
>
> |
> /*\
> title: $:/macros/danielo515/get_unique_values.js
> type: application/javascript
> module-type: macro
>
> This macro returns the list of values that exists only on tiddler A.
> It expects a list of \n separated values on each tiddler.
>
> \*/
> (function(){
>
> /*jslint node: true, browser: true */
> /*global $tw: false */
> "use strict";
>
> /*
> Information about this macro
> */
>
> exports.name = "getunique";
>
> exports.params = [
> {name: "A"},
> {name: "B"}
> ];
>
> /*
> Run the macro
> */
> exports.run = function(A,B){
> var a=($tw.wiki.getTiddlerText(A) ||""),
> b=($tw.wiki.getTiddlerText(B) ||""),
> a_values= a.split('\n'),
> b_values= b.split('\n'),
> result = [];
>
> a_values.forEach(function(a_value){
> if(b_values.indexOf(a_value) === -1)
> result.push(a_value);
> });
> console.log(result.length," unique values remains");
> return "```\n" + result.join('\n') + "\n```";
> };
>
> })();
> |
>
>
> --
> 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]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at http://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/dc66884b-c46a-4664-bbe3-0ae8dd3fcc4f%40googlegroups.com
> <https://groups.google.com/d/msgid/tiddlywiki/dc66884b-c46a-4664-bbe3-0ae8dd3fcc4f%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.
--
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/BLU436-SMTP134831C2A7902C7EC79C277CEFD0%40phx.gbl.
For more options, visit https://groups.google.com/d/optout.