WillFa said:highlight("pie", "red", "green")
Why would a user set up a trigger to match pie, choose the UI settings, and then add scripting to do the same thing? Do this in the script file, sure, then you can addxml the whole trigger yourself.
They don't. Yes, if you want to highlight "pie" anywhere you'd just use a dedicated trigger, but it's often the case that you want to highlight items only in specific lines, or multiple times within the same line, or color things only under specific circumstances. Using this library, you can do all these thing from a single trigger, which is logically where it belongs.
WillFa said:Or a user can use the UI...
<triggers>
<trigger
custom_colour="14"
enabled="y"
keep_evaluating="y"
match="Twisol"
regexp="y"
sequence="100"
>
</trigger>
<trigger
custom_colour="3"
enabled="y"
keep_evaluating="y"
match="tell"
regexp="y"
sequence="100"
>
</trigger>
</triggers>
The UI only allows highlighting of the entire matched contents, which can make it more complex than it should be to color specific parts. The Achaea user, as I said, was demonstrating a method using ColourTell to re-colour part of a matched line by gagging and re-echoing, which is both cumbersome and error-prone when two triggers do it to the same line. My way keeps the highlighting of a given line within the trigger that matches it, and two such triggers can cooperate, because the later styles are "painted" on top of the previous ones.
WillFa said: Are you reinventing the wheel or something?
No.
WillFa said: A regular expression of an unanchored literal will only color the literal (not the whole line).
Keep Evaluating will allow multiple highlight triggers to color (fragments of) the same line.
You can pick colors, bold, italic, underline etc right in the gui...
You can AddXML a trigger in scripting...
Quite. This is all how it works internally, except they're also one-shot so they don't apply themselves to later lines, effectively removing themselves immediately. (I'm also using my reflex.lua library so the heavy-lifting of the XML is done for me.)
Everything about this experimental library is totally possible without it. The point is that it makes it easier and clearer to do the task it's designed for. That's why I wrote Reflex, and PPI, and devised my structured-plugin paradigm. When you're highlighting part of a specific line, you really don't care to deal with the conceptual overhead of an extra trigger (or more) to deal with the highlighting, and there's always the possibility that it won't even match and deactivate itself, leaving you to handle that somehow yourself.
It's even entirely possible without this particular suggestion, as I've noted. But this would make it a bit cleaner, because everything you pass will be directly related to highlighting. |