Home Download Buy Blog Forum Support

Build result highlighting

Build result highlighting

Postby marcohu on Tue Jan 22, 2013 9:51 pm

Howdy,

I'm currently developing a plugin that occationally outputs messages in a custom panel. As there might be multi-line messages involved and I could not come up with a ''result_file_regex'' that matches such messages, I'm using custom code to perform the highlighting.

It works great, but I'm now facing the (cosmetic) problem that I don't know which scope name to use for the add_region function to match the color used by the default build results highlighting. Therefore whenever I'm using F4/Shift F4 to step through the messages, I end up with different coloring for the first line vs. the rest.

I'm attaching a screenshot for illustration. F4 causes the first line to be highligthed in blue, and the rest is highlighted in black (using custom code) but it should rather use the same blue as the first line.

The API doc only lists 'string' and 'comment' as possible values, and I could not find any information about other scope names, but it surely should be possible to use the standard build output color as well.

I'm speaking about this function:

Code: Select all
sublime.View.add_regions(key, [regions], scope, <icon>, <flags>)


I would appreciate any input. Thanks in advance.

Cheers,
Marco
Attachments
multi-line-message-highlighting.png
multi-line-message-highlighting.png (57.67 KiB) Viewed 1223 times
marcohu
 
Posts: 2
Joined: Sun Jan 20, 2013 11:41 pm

Re: Build result highlighting

Postby FichteFoll on Sat Jan 26, 2013 1:47 am

It would be nice if the text on the screenshot was actually readable.

Anyway, it seems to me that you are having problems making "result_file_regex" of an output panel match a multi-line string and you are using `view.add_regions` to colorize the background of the remaining parts of the match. The f4 and shift+f4 commands do not use a "scope" for their highlight, they make a selection. Thus, by colorizing more stuff with the same color you would just have to extend the current selection of it. You could hook into "on_selection_modified" and check for some internal view id to only modify the selection on your output window.

As for the "result_file_regex" multi-line issue: Did you try matching any of "\s\r\n" or "." with "(?m)" (probably "(?s)" but test both)?
FichteFoll
 
Posts: 406
Joined: Fri Mar 16, 2012 11:49 pm
Location: Germany

Re: Build result highlighting

Postby marcohu on Tue Jan 29, 2013 7:06 am

FichteFoll wrote:Anyway, it seems to me that you are having problems making "result_file_regex" of an output panel match a multi-line string and you are using `view.add_regions` to colorize the background of the remaining parts of the match.


Exactly!

FichteFoll wrote:The f4 and shift+f4 commands do not use a "scope" for their highlight, they make a selection. Thus, by colorizing more stuff with the same color you would just have to extend the current selection of it. You could hook into "on_selection_modified" and check for some internal view id to only modify the selection on your output window


Interesting. It didn't come to my mind to alter the existing selection. I will try that and it hopefully solves the issue. Awesome!

FichteFoll wrote:As for the "result_file_regex" multi-line issue: Did you try matching any of "\s\r\n" or "." with "(?m)" (probably "(?s)" but test both)?


I've tried different approaches and yes, I've experimented with multi-line matching - (?s) is the embedded expression needed here - but I was not able to come up with a regex that matches just one multi-line message. Not sure whether I did something wrong or the stingy quantifiers don't work my way. I always ended up with the rest of the output panel text highlighted, not only the rest of the current message highlighted, therefore the workaround with custom code.

Thanks very much for your help! Awesome project BTW. Kudos to the developer!
marcohu
 
Posts: 2
Joined: Sun Jan 20, 2013 11:41 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 11 guests