Sublime Forum

BracketHighlighter2 BETA Branch

#75

Thanks to @Eduan for create a billion tiny icons, we now have different icons when brackets are on the same line and not.

Might need to restart to see it.


0 Likes

#76

[quote=“facelessuser”]Thanks to @Eduan for create a billion tiny icons, we now have different icons when brackets are on the same line and not.

Might need to restart to see it.

[attachment=0]Screen Shot 2012-10-27 at 10.48.07 AM.png[/attachment][/quote]

Yay! You’re welcome. :smile:

Expect some Retina display support soon (as soon as I figure it out). People out there with Retina display, be ready to test and take huge screenshots.

0 Likes

#77

@Eduan before you waste too much time, you should make sure that ST2 actually uses retina gutter icons. I looked in the default theme, and there are no retina icons there. So I wonder if ST2 actually supports retina gutter icons.

0 Likes

#78

Well it does say in the changelog that it added Retina display support. And also the Soda theme has working Retina display support. So all we have to do is figure out how to make the package use Retina icons.

0 Likes

#79

I think I remember some people saying gutter icons weren’t supported. But if they are supported, all you have to do is double the size and but @2x at the end of the name.

So icon.png will have a retina version called icon@2x.png which is twice the width and twice the hight.

0 Likes

#80

OK, thanks for the info. :smile:

I did have the idea of making it double the size, but didn’t know about the @2x at the end. I will start working on them now. :smile:

Even if they’re not supported currently, they will eventually I imagine, so the earlier the better. :smile:

0 Likes

#81

Just to let people know. The next alpha is going to break your personal settings file. You will need to reconfigure it.

I have separated bracket styles from the bracket defines, so that requires the settings file to be configured differently. I also fixed a couple of bugs and tweaked some stuff.

I wanted to send out a warning before I commit so people can be prepared and not post a bunch of bug reports. It is already done, but I haven’t committed it yet. I will post back later today when I commit it.

0 Likes

#82

Here is what the new default settings file is going to look like so you can acquaint yourselves with it. Notice there will be two special styles “default” and “unmatched”; even if you remove them, they will be generated internally with some defaults. You can change the special styles, but they will always exist.

The rest of the defined styles are essentially overriding default settings. So if you create a style called “curly” and do not define the color, it will take on the “default” color etc.

Each bracket definition now only has an optional style option where you can point the definition at a style. If you leave out the style option, it will simply use “default”.

You will notice the example below I have left in optional parameters but commented them out to show what you can do, but by default, they will be using optional parameters.

[code]{
// Path to find icons at
“icon_path”: “BracketHighlighter/icons”,

// When only either the left or right bracket can be found
// this defines if the unmatched bracket should be shown.
"show_unmatched" : true,

// Rules that define find and matching brackets
// that are contained in a common scope.
// Useful for bracket pairs that are the same but
// share a common scope.  Brackets are found by
// Finding the extent of the scope and using regex
// to look at the beginning and end to identify bracket.
// Use only if they cannot be targeted with traditional bracket
// rules.
"scope_brackets": 
    // Quotes
    {
        "name": "py_single_quote",
        "open": "u?r?((?:'')?')",
        "close": "((?:'')?')",
        "style": "single_quote",
        "scopes": "string"],
        "language_filter": "whitelist",
        "language_list": "Python"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    {
        "name": "py_double_quote",
        "open": "u?r?((?:\"\")?\")",
        "close": "((?:\"\")?\")",
        "style": "double_quote",
        "scopes": "string"],
        "language_filter": "whitelist",
        "language_list": "Python"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    {
        "name": "single_quote",
        "open": "(')",
        "close": "(')",
        "style": "single_quote",
        "scopes": "string"],
        "language_filter": "blacklist",
        "language_list": "Plain text"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    {
        "name": "double_quote",
        "open": "(\")",
        "close": "(\")",
        "style": "double_quote",
        "scopes": "string"],
        "language_filter": "blacklist",
        "language_list": "Plain text"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    // Regex for different Languages
    {
        "name": "jsregex",
        "open": " *(/)",
        "close": "(/)[igm]*",
        "style": "regex",
        "scopes": "string"],
        "language_filter": "whitelist",
        "language_list": "JavaScript"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    {
        "name": "perlregex",
        "open": "(?:m|s|tr)(.|\n)",
        "close": "(.|\n)(?:[igmos]*)",
        "style": "regex",
        "scopes": "string.regexp"],
        "language_filter": "whitelist",
        "language_list": "Perl"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    {
        "name": "rubyregex",
        "open": " *(/)",
        "close": "(/)[imxo]*",
        "style": "regex",
        "scopes": "string"],
        "language_filter": "whitelist",
        "language_list": "Ruby"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    // Markdown
    {
        "name": "mditalic",
        "open": "(\\*|_)",
        "close": "(\\*|_)",
        "style": "default",
        "scopes": "markup.italic"],
        "language_filter": "whitelist",
        "language_list": "Markdown"],
        "sub_bracket_search": "true",
        "enabled": true
    },
    {
        "name": "mdbold",
        "open": "(\\*\\*|__)",
        "close": "(\\*\\*|__)",
        "style": "default",
        "scopes": "markup.bold"],
        "language_filter": "whitelist",
        "language_list": "Markdown"],
        "sub_bracket_search": "true",
        "enabled": true
    }
],

// Rule definitions for finding and matching brackets.
// Brackets are found by using regex and can use scope
// qualifiers exclude certain matches.
// Once all matches are found, the closest pair surrounding
// the cursor are selected.
"brackets": 
    // Basic brackets
    {
        "name": "curly",
        "open": "(\\{)",
        "close": "(\\})",
        "style": "curly",
        "scope_exclude": "string", "comment"],
        "scope_exclude_exceptions": "string.other.math.block.environment.latex"],
        "language_filter": "blacklist",
        "language_list": "Plain text"],
        "find_in_sub_search": true,
        "ignore_string_escape": true,
        "enabled": true
    },
    {
        "name": "round",
        "open": "(\\()",
        "close": "(\\))",
        "style": "round",
        "scope_exclude_exceptions": "string.other.math.block.environment.latex"],
        "scope_exclude": "string", "comment"],
        "language_filter": "blacklist",
        "language_list": "Plain text"],
        "find_in_sub_search": true,
        "ignore_string_escape": true,
        "enabled": true
    },
    {
        "name": "square",
        "open": "(\\)",
        "close": "(\\])",
        "style": "square",
        "scope_exclude": "string", "comment"],
        "scope_exclude_exceptions": "string.other.math.block.environment.latex"],
        "language_filter": "blacklist",
        "language_list": "Plain text"],
        "find_in_sub_search": true,
        "ignore_string_escape": true,
        "enabled": true
    },
    // Angle brackets and tags
    {
        "name": "angle",
        "open": "(<)",
        "close": "(>)",
        "style": "angle",
        "scope_exclude": "string", "comment", "keyword.operator"],
        "language_filter": "whitelist",
        "language_list": "HTML", "HTML 5", "XML", "PHP", "HTML+CFML", "ColdFusion", "ColdFusionCFC"],
        "plugin_library": "bh_modules.tags",
        "enabled": true
    },
    // CSSedit groups
    {
        "name": "cssedit_groups",
        "open": "(/\\* *@group .*\\*/)",
        "close": "(/\\* *@end *\\*/)",
        "style": "default",
        "scope_exclude": ],
        "language_filter": "whitelist",
        "language_list": "CSS"],
        "enabled": true
    },
    // Ruby conditional statements
    {
        "name": "ruby",
        "open": "(^\\s*\\b(?:if|until|unless|while|begin|class|module|def\\b\\s*[a-zA-Z_]+)|do)\\b",
        "close": "\\b(end)\\b",
        "style": "default",
        "scope_exclude": "string", "comment"],
        "plugin_library": "bh_modules.rubykeywords",
        "language_filter": "whitelist",
        "language_list": "Ruby"],
        "enabled": true
    },
    // C/C++ compile switches
    {
        "name": "c_compile_switch",
        "open": "(\\#(?:if|ifdef|ifndef))\\b",
        "close": "(\\#endif)\\b",
        "style": "default",
        "scope_exclude": "string", "comment"],
        "language_filter": "whitelist",
        "language_list": "C++", "C"],
        "enabled": true
    }
],

// Define region highlight styles
"bracket_styles": {
    // "default" and "unmatched" styles are special
    // styles. If they are not defined here,
    // they will be generated internally with
    // internal defaults.

    // "default" style defines attributes that
    // will be used for any style that does not
    // explicitly define that attribute.  So if
    // a style does not define a color, it will
    // use the color from the "default" style.
    "default": {
        "icon": "dot",
        "color": "brackethighlighter.default",
        "style": "underline"
    },

    // This particular style is used to highlight
    // unmatched bracekt pairs.  It is a special
    // style.
    "unmatched": {
        "icon": "question",
        // "color": "brackethighlighter.unmatched",
        "style": "outline"
    },
    // User defined region styles
    "curly": {
        "icon": "curly_bracket"
        // "color": "brackethighlighter.curly",
        // "style": "underline"
    },
    "round": {
        "icon": "round_bracket"
        // "color": "brackethighlighter.round",
        // "style": "underline"
    },
    "square": {
        "icon": "square_bracket"
        // "color": "brackethighlighter.square",
        // "style": "underline"
    },
    "angle": {
        "icon": "angle_bracket"
        // "color": "brackethighlighter.angle",
        // "style": "underline"
    },
    "tag": {
        "icon": "tag",
        // "color": "brackethighlighter.tag",
        "style": "outline"
    },
    "single_quote": {
        "icon": "single_quote"
        // "color": "brackethighlighter.quote",
        // "style": "underline"
    },
    "double_quote": {
        "icon": "double_quote"
        // "color": "brackethighlighter.quote",
        // "style": "underline"
    },
    "regex": {
        "icon": "regex"
        // "color": "brackethighlighter.quote",
        // "style": "underline"
    }
},

// Match brackets only when the cursor is touching the inside of the bracket
"match_only_adjacent": false,

// Character threshold to search
"search_threshold": 5000,

// Set mode for string escapes to ignore (regex|string)
"bracket_string_escape_mode": "string",

// Set max number of multi-select brackets that will be searched automatically
"auto_selection_threshold" : 10,

// Disable gutter icons when doing multi-select
"no_multi_select_icons": false,

/* Plugin settings */

// Style to use for matched tags
"tag_style": "tag",

// Determine which style of tag-matching to use in which syntax
"tag_mode": {
    "xhtml": "XML"],
    "html": "HTML", "HTML 5", "PHP"],
    "cfml": "HTML+CFML", "ColdFusion", "ColdFusionCFC"]
}

}
[/code]

0 Likes

#83

Looks good, thanks for the udpate! (I’m glad I haven’t configured it myself. :stuck_out_tongue:)

0 Likes

#84

Committed new alpha. Make sure to restart after upgrade, and remember it might not be working because you need to reconfigure you personal settings file and keymap file for this new alpha. Other big thing is I added menu items and command palette stuff etc.

CHANGES:

  • rework how styles are assinged to brackets
  • update bh_core.sublime-settings to handle new style changes and other changes
  • fix Scope Bracket mapping issue
  • change “invalid” setting to “unmatched”
  • make sure always storing selections
  • tab stop shortcut is now defined in Default.sublime-keymap instead of in Example.sulbime-keymap
  • due to rework change tag example shortcuts to refrence “angle” type brackets instead of “tag”
  • update bracket plugins references to “angle” type brackets instead of “tag” where applicable
  • make small fixes and adjustments to bh_wrapping.sublime-settings
  • update rubykeywords.py to reflect changes in bracket plugins in regards to styles
  • tags.py now gets tag style from bh_core.sublime-settings
  • provide command palette command file for bracket plugin commands
  • provide menu under Preferences->Packages to access preference files and keymap files
  • provide menu under Tools->Packages for BracketHighlighter plugin commands
  • update readme
  • remove example.png file
0 Likes

#85

I am hoping this is the one and only time I break the plugin for current users. All changes moving forward should hopefully be backwards compatible.

0 Likes

#86

What was the exact change that made this underline/icon change from the pink in the previous version (I’m assuming it somehow got it from the syntax highlighting being used?) to the white in this latest commit?:

What was your logic behind this change?

0 Likes

#87

Originally I had it hard coded to use the color of the scope “keyword”. This is just stuff I was using in testing. I changed how the region styles are associated with the bracket definition (i separated them, it makes more sense this way).

But the reason why it is white, is because everything by default is now linked to the default color scope “brackethighlighter.default”. This is how I plan to release it out of the box. You can add this scope to your color scheme file and define it to whatever color you want. Or you can change the scope to one that exists in your color scheme file, or create different scopes in your color scheme file. All brackets are probably white now (if your color scheme foreground color is white) because I am no longer defining individual colors anymore. You must do this by copying the settings file to the User folder and then change it to your hearts content.

It doesn’t make sense for me to try and define scopes for different brackets because in some color scheme files what I pick may look horrible while in others it may look good. So I created “brackethighlighter.default” (which probably does not exist in your color scheme file, which means the color will just be your foreground color).

I hope that makes sense. The plugin provides the functionality, you provide the color, style, rules etc you want. I provide some basic rules though.

0 Likes

#88

This is an alpha, so things can change radically. But hopefully, this is the last radical change.

0 Likes

#89

[quote=“facelessuser”]Originally I had it hard coded to use the color of the scope “keyword”. This is just stuff I was using in testing. I changed how the region styles are associated with the bracket definition (i separated them, it makes more sense this way).

But the reason why it is white, is because everything by default is now linked to the default color scope “brackethighlighter.default”. This is how I plan to release it out of the box. You can add this scope to your color scheme file and define it to whatever color you want. Or you can change the scope to one that exists in your color scheme file, or create different scopes in your color scheme file. All brackets are probably white now (if your color scheme foreground color is white) because I am no longer defining individual colors anymore. You must do this by copying the settings file to the User folder and then change it to your hearts content.

It doesn’t make sense for me to try and define scopes for different brackets because in some color scheme files what I pick may look horrible while in others it may look good. So I created “brackethighlighter.default” (which probably does not exist in your color scheme file, which means the color will just be your foreground color).

I hope that makes sense. The plugin provides the functionality, you provide the color, style, rules etc you want. I provide some basic rules though.[/quote]

Is it possible to somehow grab the color from the color of the bracket being highlighted? This would guarantee it would still look OK with a given color scheme and provide a more visually appealing default for BH2.

0 Likes

#90

The way the ST2 API works is that you set a region to highlight, and you give your scope. To try and dynamically pick a scope would turn out horrible depending on what is getting highighlighted. What if the the region being highlighted spans multiple scopes, which scope would I pick? And in the case of curly, and square etc. you would just get a boring white with your current color scheme.

The way I personally do it is assign different brackets scopes that I make up “brackethighighter.curly”, “brackethighlighter.square”, etc. And then I define them in my theme file. You can do this if you like.

Right now ruby keywords are linked to the default. If you change your settings file to this, you will have red for the default.

[pre=#2D2D2D] “default”: {
“icon”: “dot”,
“color”: “keyword”,
“style”: “underline”
},[/pre]

If you want greater control, you can create a special style for ruby keywords.

[pre=#2D2D2D] 191 // Ruby conditional statements
192 {
193 “name”: “ruby”,
194 “open”: “(^\s*\b(?:if|until|unless|while|begin|class|module|def\b\s*[a-zA-Z_]+)|do)\b”,
195 “close”: “\b(end)\b”,
196 “style”: “rubykeywords”,
197 “scope_exclude”: “string”, “comment”],
198 “plugin_library”: “bh_modules.rubykeywords”,
199 “language_filter”: “whitelist”,
200 “language_list”: “Ruby”],
201 “enabled”: true
202 },

…

242 “rubykeywords”: {
243 “icon”: “dot”,
244 “color”: “keyword”,
245 “style”: “underline”
246 },[/pre]

Anything you omit in the style object defers to what is in the default style.

If you want even greater control, make up a scope and add it to your theme file.

[pre=#2D2D2D] “rubykeywords”: {
“icon”: “dot”,
“color”: “madeup.scope”,
“style”: “underline”
},[/pre]

[pre=#2D2D2D]
name
Made up Scope
scope
madeup.scope
settings

foreground
#99CC99

[/pre]

The sky is the limit.

0 Likes

#91

I was envisioning just picking the outermost scope for the coloring. Regarding the braces, I like the white coloring that matches. The matching colors are the least distracting while still being useful with a flare of style. Is there an easier way to do this than manually go and set the color to match for every single “bracket” type?

0 Likes

#92

Some people want one color that all brackets use, some people want the bracket to be the same as the bracket being emphasized, some want contrast between the two to make it easier to see. I run into a problem were I can’t please everyone with styling, so the easiest way is to make it completely configurable. If I make it simpler for you to style it in your way, it may make it less simpler for people to style in their way. So I make it basic, but straight forward. Create style profiles and assign them to one or more brackets.

You don’t have to create separate style profiles for every bracket. You can create just a couple and assign them to multiple brackets. You can remove them all and just use the default one.

On top of that, changing the colors isn’t something you are going to be doing everyday. It is one of those things were you tweak it the first time, and then you forget about it. If it was a task that was going to be done everyday, I can see where it would get troublesome, but really, this is something you should tweak how you like and forget about it.

0 Likes

#93

[quote=“facelessuser”]

Some people want one color that all brackets use, some people want the bracket to be the same as the bracket being emphasized, some want contrast between the two to make it easier to see. I run into a problem were I can’t please everyone with styling, so the easiest way is to make it completely configurable. If I make it simpler for you to style it in your way, it may make it less simpler for people to style in their way. So I make it basic, but straight forward. Create style profiles and assign them to one or more brackets.

You don’t have to create separate style profiles for every bracket. You can create just a couple and assign them to multiple brackets. You can remove them all and just use the default one.

On top of that, changing the colors isn’t something you are going to be doing everyday. It is one of those things were you tweak it the first time, and then you forget about it. If it was a task that was going to be done everyday, I can see where it would get troublesome, but really, this is something you should tweak how you like and forget about it.[/quote]

I know, I was just asking if there was an easier way to do this (eg. somehow set it as the default behavior for everything). Nothing can ever please everybody; I just thought this would be a nice option to have and a better default than simply using the foreground color. I’m not suggesting you should abandon customization, that’s silly. I’m just saying that something like:

"default": { "color": "brackethighlighter.bracketcolor", } would be a nice option to have.

0 Likes

#94

[quote=“Gnintendo”]

Some people want one color that all brackets use, some people want the bracket to be the same as the bracket being emphasized, some want contrast between the two to make it easier to see. I run into a problem were I can’t please everyone with styling, so the easiest way is to make it completely configurable. If I make it simpler for you to style it in your way, it may make it less simpler for people to style in their way. So I make it basic, but straight forward. Create style profiles and assign them to one or more brackets.

You don’t have to create separate style profiles for every bracket. You can create just a couple and assign them to multiple brackets. You can remove them all and just use the default one.

On top of that, changing the colors isn’t something you are going to be doing everyday. It is one of those things were you tweak it the first time, and then you forget about it. If it was a task that was going to be done everyday, I can see where it would get troublesome, but really, this is something you should tweak how you like and forget about it.
I know, I was just asking if there was an easier way to do this (eg. somehow set it as the default behavior for everything). Nothing can ever please everybody; I just thought this would be a nice option to have and a better default than simply using the foreground color. I’m not suggesting you should abandon customization, that’s silly. I’m just saying that something like:

"default": { "color": "brackethighlighter.bracketcolor", } would be a nice option to have.[/quote]

That is what I was saying earlier. That already exists. It just isn’t dynamic (grap the actual scope of the bracket).

It makes it tough because the region has to be the same for all in the group, so you can’t really scan every bracket selection, or you would have to create a special region for every bracket instead of bracket groups, and ensure the region key names don’t overlap and then keep a list so you can clear them all. It is a lot of added complexity.

0 Likes