Home Download Buy Blog Forum Support

BracketHighlighter

Re: BracketHighlighter

Postby cOrange on Wed Sep 25, 2013 9:55 am

Thanks for the reply. None of these are essential in any way, so no worries.


facelessuser wrote:Doesn't really work. This is a limitation of the Sublime API. I have tried setting the background to match the syntax background and tried changing font color to try and simulate the effect, but it just doesn't work well with sublime. Sorry. If this ever changes in the sublime API moving forward, then I will gladly add the feature.


It's alright; it works well enough as it is, I think: https://dl.dropboxusercontent.com/u/379 ... acket.tiff .

Thanks!
cOrange
 
Posts: 3
Joined: Sun Sep 22, 2013 11:17 pm

Re: BracketHighlighter

Postby tito on Fri Sep 27, 2013 3:29 am

Hello!, previously in the past ST2 version, the bracket/character was highlighted when clicking to the right of it, like this: ")|", now this will trigger to search the bracket to the right of it, instead of the clickedone .. ahh! Is there any setting to return to the old behaviour? It was more user-friendly. :roll:
Thanks for great package!
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: BracketHighlighter

Postby facelessuser on Fri Sep 27, 2013 3:57 am

tito wrote:Hello!, previously in the past ST2 version, the bracket/character was highlighted when clicking to the right of it, like this: ")|", now this will trigger to search the bracket to the right of it, instead of the clickedone .. ahh! Is there any setting to return to the old behaviour? It was more user-friendly. :roll:
Thanks for great package!


When I completely re-wrote the plugin to add in custom brackets, that feature didn't get carried over, but it is on my list of things to look into bringing back. I had kind of grown to like it working only from within the brackets, but I understand that is a personal preference.

I've been pretty busy, but hopefully sometime soon, I can take a look at plugin issues and start working through them again.
facelessuser
 
Posts: 1571
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby gregor.hoch on Thu Oct 03, 2013 8:05 am

I am trying to add latex tables and figures as brackets but somehow it's not working. Here is my attempt:

Code: Select all
{
            "name": "latex_floats",
            "open": "(\\begin\\{sidewaystable\\})",
            "close": "(\\end\\{sidewaystable\\})",
            "style": "default",
            "scope_exclude": ["string", "comment"],
            "language_filter": "whitelist",
            "language_list": ["LaTeX"],
            "enabled": true
}


As a result, I only get the `\end{sidewaystable}` sourrounded with a black line and a ? indicating that ST is unable to find the opening bracket. Any idea why?

One more questions: If this works, I would like to extend it to something like "open": "(\\begin\\{(table|sidewaystable|figure|sidewaysfigure|algorithm)\\})". But I don't think that works because only one captureing group is allowed. That is the alternative? That's a simple regex question, I guess.
gregor.hoch
 
Posts: 144
Joined: Sat Oct 01, 2011 7:54 pm

Re: BracketHighlighter

Postby facelessuser on Thu Oct 03, 2013 5:57 pm

gregor.hoch wrote:One more questions: If this works, I would like to extend it to something like "open": "(\\begin\\{(table|sidewaystable|figure|sidewaysfigure|algorithm)\\})". But I don't think that works because only one captureing group is allowed. That is the alternative? That's a simple regex question, I guess.


You can use non-capturing groups: (?:something|something else|etc). You need one and only one capturing group, but you can have as many non-capturing groups as you need.

If you are still having trouble, please provide some example Latex Code I can test with. I don't use every language, so I always ask people provide me with example code, a clear explanation of what the they want BH to highlight, and their best attempting at creating the rules and/or scripts needed. This helps save me time.
facelessuser
 
Posts: 1571
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby gregor.hoch on Fri Oct 04, 2013 6:42 am

facelessuser wrote:
gregor.hoch wrote:One more questions: If this works, I would like to extend it to something like "open": "(\\begin\\{(table|sidewaystable|figure|sidewaysfigure|algorithm)\\})". But I don't think that works because only one captureing group is allowed. That is the alternative? That's a simple regex question, I guess.


You can use non-capturing groups: (?:something|something else|etc). You need one and only one capturing group, but you can have as many non-capturing groups as you need.

If you are still having trouble, please provide some example Latex Code I can test with. I don't use every language, so I always ask people provide me with example code, a clear explanation of what the they want BH to highlight, and their best attempting at creating the rules and/or scripts needed. This helps save me time.


Yes, of course. Here is some code

Code: Select all
\begin{sidewaystable}
\caption{this is a sidewaytable}

\end{sidewaystable}

\begin{table}
\caption{this is a table}

\end{table}

\begin{figure}
\caption{figure}

\end{figure}


And my is modified entry in the brackets array in bh_core.sublime-settings.

Code: Select all
{
            "name": "latex_floats",
            "open": "(\\begin\\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\\})",
            "close": "(\\end\\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\\})",
            // "open": "(\\begin\\{sidewaystable\\})",
            // "close": "(\\end\\{sidewaystable\\})",
            "style": "default",
            "scope_exclude": ["string", "comment"],
            "language_filter": "whitelist",
            "language_list": ["LaTeX"],
            "enabled": true
}


I would like to highlight
\begin{sidewaystable}...\end{sidewaystable}
\begin{table}...\end{table}
\begin{figure}...\end{figure}

But I only get the `\end{..}` sourrounded with a black line and a ? indicating that ST is unable to find the opening bracket. Any idea why?

Thanks!
gregor.hoch
 
Posts: 144
Joined: Sat Oct 01, 2011 7:54 pm

Re: BracketHighlighter

Postby facelessuser on Sat Oct 05, 2013 3:37 pm

The problem was simply you have to escape backslashes in regex but also escape backslashes in the JSON settings strings as well, which can cause slightly unintuitive escapeing:

So you want this:

Code: Select all
\\begin\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\})


So you but this in your settings:

Code: Select all
\\begin\\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\\})


but when the regex is read in from the JSON setting string, the regex looks like this:

Code: Select all
\begin\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\})


So basically "\begin" wasn't sufficiently escaped in the JSON setting string to translate to an appropriate escaped regex...I know, I know this is the convoluted stuff that happens when you represent a regex expression in a string.

This is what you need:
        {
"name": "latex_floats",
"open": "(\\\\begin\\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\\})",
"close": "(\\\\end\\{(?:table|sidewaystable|figure|sidewaysfigure|algorithm)\\})",
// "open": "(\\begin\\{sidewaystable\\})",
// "close": "(\\end\\{sidewaystable\\})",
"style": "default",
"scope_exclude": ["string", "comment"],
"language_filter": "whitelist",
"language_list": ["LaTeX"],
"enabled": true
},
facelessuser
 
Posts: 1571
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby Voaxeyr on Sun Oct 06, 2013 8:34 pm

(Failed to post the first time, trying again?)
Hello!
I'm sorry if it has been asked before, but I was playing with bracket highlighter (I'm still learning Sublime Text itself) and I was wondering if it was possible to only highlight the bracket itself, not the block as a whole...

Desired: (from Vim)
Image

Actual: (from sublime)
Image
Voaxeyr
 
Posts: 6
Joined: Wed Sep 25, 2013 6:00 pm

Re: BracketHighlighter

Postby facelessuser on Mon Oct 07, 2013 12:54 am

@Voaxeyr The readme explains all of this here: https://github.com/facelessuser/Bracket ... ight-style

But to directly answer your question, you can copy the bh_core.sublime-settings file to your Packages/User folder and change the default to solid like shown below:

        "default": {
"icon": "dot",
"color": "brackethighlighter.default",
"style": "solid"
},


If you want to change a specific bracket to be this way, and others to be different, you can can tweak them on an individually; all of this is covered in the readme.
facelessuser
 
Posts: 1571
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby ceroz on Sun Oct 20, 2013 12:15 pm

Is there any website with style examples ? I see there's a lot nice color schemes, no need to make it from scratch.
ceroz
 
Posts: 5
Joined: Sun Oct 20, 2013 12:11 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 6 guests