Highlight Trigger code

Post Reply
Posts: 43
Joined: Sun Jul 12, 2009 1:25 am

Highlight Trigger code

Post by eraldo »

What code would correspond to the behavior of the color trigger?
I want to have it in oder to change the colors by script.

I tried this:
selectString( matches[2], 1 )
fg( "red" )

For a pattern like this:
^I have (\w+) in my pocket$

that would work...

But with this:
^I have (\w+) and (\w+) in my pocket$
it would only color on occurrence.
> I could change the number to 2 [selectString( matches[2], 2 )]
but what if I have 2 patterns....

^I have (\w+) in my pocket$
^I have (\w+) and (\w+) in my pocket$

> that works with the color trigger!
but I can't find the code that does the same thing.
Last edited by eraldo on Sun Sep 06, 2009 12:37 pm, edited 1 time in total.

User avatar
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Color Trigger code

Post by Heiko »

1. Checkout the selectCaptureGroup() function.
2. selectString( matches[2], 1 ) for the first pattern and selectString( matches[3],1) for the second, selectSTring( matches[n], n ) for the n-th occurence of the n-th+1 pattern.
3. if you chose the "match all" trigger option, the table matches[] will contain all occurences of the defined pattern in the line e. g. pattern (\d+) with the "match all" trigger option will get you a table matches containing all numbers contained in the line.
4. Your topic title is misleading. Color triggers can only hold color pattern i. e. the trigger will trigger whenever the defined color can be found in the current line. If you add further text or regex based patterns to the trigger the trigger will fire either if the color is true or the pattern is true, what will not be what you might expect. You should keep color triggers to color triggering only and then use a proper trigger chain for further regex or text pattern based processing.

Post Reply