Home Download Buy Blog Forum Support

BracketHighlighter2 BETA Branch

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Wed Oct 24, 2012 3:38 pm

Man, you are awesome! Thanks a lot, now looks beautiful! :)

Btw, there is a way we can reward you for the awesome job you do? A paypal account maybe? ;)
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Wed Oct 24, 2012 3:53 pm

iamntz wrote:Man, you are awesome! Thanks a lot, now looks beautiful! :)

Btw, there is a way we can reward you for the awesome job you do? A paypal account maybe? ;)


Yeah, when you click it, it references a different project, but you can go here.

Image

vitaLee wrote:@facelessuser is that a custom color scheme you're using?
care to share?

Sure, it is a modified Tomorrow-Night-Eighties theme.

Here is the gist https://gist.github.com/3946761.

It isn't perfect yet. Tomorrow-Night by default highlights some things I don't want it to in some languages, I have changed most of those cases though. Also, there is a number of personal scopes in there you can keep or remove. And one more thing, some things that you see mine highlight won't highlight on yours because I use some modified languages that insert some special scopes for my theme to trigger off of, but in general, it should work fine for you.
facelessuser
 
Posts: 1550
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Thu Oct 25, 2012 6:24 pm

Found a small bug (i think).
So...

If the matching group consist in more than one char, like, let's say <?php ?> thing and one it's invalid, it should stop highlight when you focus it. Don't know if this make sense, but try to look at the movie (i only moved left/right with arrow keys):

http://img.iamntz.com/jing/2012-10-25_2114.swf


//edit:
actually scratch that, me dumb! :)
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Thu Oct 25, 2012 7:11 pm

Ok, so, as i said, me dumb :D
I'm trying to make ST to also highlight if/endif foreach/endforeach and so on in php. What i have now (after like 50 different combinations or so) is this:

Code: Select all
open": "(^if|foreach|while.+:$)",
"close": "(^endif|endforeach|endwhile;$)",


But will not match correctly what i need (php have two ways of doing blocks; one is with if/endif and the other is with curly braces)

However, if i'll do only this:

Code: Select all
"open": "(^if.+:$)",
"close": "(^endif;$)",


works good...ish. Because will make things red (which is an error) when i focus inside of the condition:
Image

While things are peachy when i'm inside of the block:
Image

What do i do wrong?

Thanks!
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Thu Oct 25, 2012 7:58 pm

iamntz wrote:Ok, so, as i said, me dumb :D
I'm trying to make ST to also highlight if/endif foreach/endforeach and so on in php. What i have now (after like 50 different combinations or so) is this:

Code: Select all
open": "(^if|foreach|while.+:$)",
"close": "(^endif|endforeach|endwhile;$)",


But will not match correctly what i need (php have two ways of doing blocks; one is with if/endif and the other is with curly braces)

However, if i'll do only this:

Code: Select all
"open": "(^if.+:$)",
"close": "(^endif;$)",


works good...ish. Because will make things red (which is an error) when i focus inside of the condition:
Image

While things are peachy when i'm inside of the block:
Image

What do i do wrong?

Thanks!


You are doing nothing wrong. What you need is a bracket plugin that taps into the compare event. During that event, you would need to compare the values to help sort out which closing bracket goes with which opening bracket. Give me an hour or so and I will try and show you what I mean. You are diving into undocumented awesomeness.
facelessuser
 
Posts: 1550
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Thu Oct 25, 2012 8:19 pm

Okay, I got to it quite a bit earlier...

Tweak this to your liking:
        {
"name": "php_keywords",
"open": "^\\s*(if|foreach|while.+:$)",
"close": "^\\s*(endif|endforeach|endwhile;$)",
"icon": "dot",
"color": "brackethighlighter.tag",
"style": "underline",
"language_filter": "whitelist",
"scope_exclude": ["string", "comment"],
"language_list": ["HTML", "HTML 5", "XML", "PHP", "HTML+CFML", "ColdFusion", "ColdFusionCFC"],
"plugin_library": "User.phpkeywords",
"enabled": true
},


Here is the awesome sauce...save as User/phpkeywords.py
def compare(name, first, second, bfr):
return "end" + bfr[first.begin:first.end] == bfr[second.begin:second.end]


Not so bad eh?
facelessuser
 
Posts: 1550
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby vitaLee on Thu Oct 25, 2012 8:26 pm

is it a default behaviour for Sublime to add icon in the gutter for each line of a multiline underlined (*mouthful*) region, or it's something you control?
i found myself exploitinhg BH2 in attempt to match Obj-C @interface @implementation directives and noticed if i use style:underline for each line of the opening "bracket" there's an icon in gutter, while the same is not true for outline, solid (icon only on first line).
vitaLee
 
Posts: 150
Joined: Tue Dec 27, 2011 11:10 pm

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Thu Oct 25, 2012 8:29 pm

Sorry, got a little careless:

def compare(name, first, second, bfr):
opening = bfr[first.begin:first.end]
closing = bfr[second.begin:second.end]
match = False
if opening.startswith("while"):
if closing.startswith("endwhile"):
match = True
else:
match = "end" + bfr[first.begin:first.end] == bfr[second.begin:second.end]
return match


That should be better.
facelessuser
 
Posts: 1550
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby facelessuser on Thu Oct 25, 2012 8:33 pm

vitaLee wrote:is it a default behaviour for Sublime to add icon in the gutter for each line of a multiline underlined (*mouthful*) region, or it's something you control?
i found myself exploitinhg BH2 in attempt to match Obj-C @interface @implementation directives and noticed if i use style:underline for each line of the opening "bracket" there's an icon in gutter, while the same is not true for outline, solid (icon only on first line).


Underline is a trick. It isn't like a normal region. There is no underline style really. There is an option in Sublime that says if a region is size 0, you can render it as an underline. So, to simulate an underline region, I take region X, Y and break it up into a series of zero size regions. So really an underline (y-x) regions, not one. That is why multi-line will show multiple icons. Because each underlined character is its own region.
facelessuser
 
Posts: 1550
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter2 Alpha Branch

Postby iamntz on Fri Oct 26, 2012 3:58 am

Thanks! Works... partially :)

because it also match if(){} expressions (and it shouldn't)

what i came up is this pattern:
Code: Select all
            "open": "^\\s*(if|foreach|while).*:$",
            "close": "^\\s*(endif|endforeach|endwhile;$)"


Thing is... while in regexbuddy works just fine, in editor it doesn't. Most likely i do some escaping wrong. Any idea which is that? Thanks!

Btw, i noticed that if there is an error somewhere in the config file, the plugin stop to works until i restart ST. It's a bug, a feature or a bit of both? :D
iamntz
 
Posts: 898
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: Yahoo [Bot] and 6 guests