Home Download Buy Blog Forum Support

BracketHighlighter

Re: BracketHighlighter

Postby farfromrefuge on Fri Jan 17, 2014 1:51 pm

First thank you for that great plugin! Can't work without it.

Now i am looking at feature present in most editors, select the bracket scope content on double mouse click on bracket. This is very useful to select arrays and such.

Now i was wondering if that was possible with you plugin (maybe using command) without breaking the normal behaviour of double click (select word)
Finally it would need to select the brackets with it. i mention that because by using select scope content it doesnt actually select the brackets.

Thanks
farfromrefuge
 
Posts: 38
Joined: Mon Oct 19, 2009 11:49 am

Re: BracketHighlighter

Postby facelessuser on Fri Jan 17, 2014 3:03 pm

farfromrefuge wrote:Now i am looking at feature present in most editors, select the bracket scope content on double mouse click on bracket. This is very useful to select arrays and such.

Now i was wondering if that was possible with you plugin (maybe using command) without breaking the normal behavior of double click (select word)

Honestly, the current mouse API in Sublime sucks. I don't think this can be done reliably.

facelessuser wrote:Finally it would need to select the brackets with it. i mention that because by using select scope content it doesn't actually select the brackets.

I plan on adding a variant of the current command to select brackets as well https://github.com/facelessuser/Bracket ... issues/132 ...when I get some time and feel like working on it :).
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby iamntz on Fri Jan 17, 2014 3:38 pm

I „fixed” the select the whole bracket scope by using this snippet (in .sublime-mousemap file, obviously)

Code: Select all
  {
    "button": "button1", "count": 1, "modifiers": ["button2"],
    "command": "expand_selection", "args": {"to": "brackets"},
    "press_command": "drag_select"
  }


It doesn't work on double click, but it works by holding click2 then press on click1 buttons.
iamntz
 
Posts: 910
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter

Postby facelessuser on Fri Jan 17, 2014 4:39 pm

iamntz wrote:I „fixed” the select the whole bracket scope by using this snippet (in .sublime-mousemap file, obviously)

Code: Select all
  {
    "button": "button1", "count": 1, "modifiers": ["button2"],
    "command": "expand_selection", "args": {"to": "brackets"},
    "press_command": "drag_select"
  }


It doesn't work on double click, but it works by holding click2 then press on click1 buttons.

This doesn't really "fix" it per se. BH selects more than common curly, round, and square brackets. BH has a number of custom brackets as well. Also the algorithm for built in ST bracket matching is different than BH, so this won't always select what you see BH targeting (ST algorithm can be sometimes inconsistent with brackets next to each other, at least it use to be...haven't checked recently).

The option of mouse modifier might be a nice touch though. As soon as I add the alternative bracket selection command (or command parameter), you should be able to use something like iamntz posted above for the BH variant that will target custom brackets as well.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby iamntz on Fri Jan 17, 2014 6:57 pm

This doesn't really "fix" it per se.

I know, that's why i used quotes ;)

Anyhow, for css(sass), php and js, this works every single time. Since the API sucks, we work with what we have :mrgreen:
iamntz
 
Posts: 910
Joined: Fri Apr 29, 2011 8:52 am
Location: Romania

Re: BracketHighlighter

Postby facelessuser on Fri Jan 17, 2014 7:17 pm

iamntz wrote:I know, that's why i used quotes

Man I completely missed those :).

Anyways, thanks for sharing. I don't use mouse maps at all, so it is nice to see things like that work...I should play around with the mouse maps a bit more.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby facelessuser on Mon Jan 20, 2014 5:14 am

I added a flag for the bracket select command to always select the tags with content. So by just taking the current command and adding the always_include_brackets argument, you can select the content and tags:

    // Select text including brackets
{
"keys": ["ctrl+alt+super+d"],
"command": "bh_key",
"args":
{
"lines" : true,
"plugin":
{
"type": ["__all__"],
"command": "bh_modules.bracketselect",
"args": {"always_include_brackets": true}
}
}
},


Pair that with the mouse trick, and that should do it.
facelessuser
 
Posts: 1575
Joined: Tue Apr 05, 2011 7:38 pm

Re: BracketHighlighter

Postby farfromrefuge on Mon Jan 20, 2014 9:23 am

facelessuser wrote:
farfromrefuge wrote:Now i am looking at feature present in most editors, select the bracket scope content on double mouse click on bracket. This is very useful to select arrays and such.

Now i was wondering if that was possible with you plugin (maybe using command) without breaking the normal behavior of double click (select word)

Honestly, the current mouse API in Sublime sucks. I don't think this can be done reliably.

no problem, thanks for answering !
farfromrefuge
 
Posts: 38
Joined: Mon Oct 19, 2009 11:49 am

Re: BracketHighlighter

Postby thematrix on Thu Feb 06, 2014 3:16 am

I can't seem to get the mouse thing to work at all. The log says it's firing, but nothing happens. Any ideas?

And thanks to the dev for adding that new always_include_brackets option. :D
thematrix
 
Posts: 3
Joined: Wed Jul 31, 2013 4:02 am

Re: BracketHighlighter

Postby adamal on Sat Feb 08, 2014 5:57 pm

@facelessuser
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
},


Am I correct in assuming that this will not work with nested constructs? E.g.:

Code: Select all
\begin{figure}[thb]
    \begin{center}
         \includegraphics[]{Fig_Geometric_Nonlinear_Examples/Roll-up_Dyn/timegeo1.eps}
    \end{center}
\end{figure}


I would think that it would be necessary to include an additional captured group in the open pattern, that was searched for in the close pattern. To try and get this to work I've been trying to hook up to the ht/xml tag matching. I tried adding the following (copying //HTML, and modifying the ends of the regex):

Code: Select all
// LaTeX \begin{(...)} \end{(...)}
{
    "name": "latex",
    "open": "(\\\\begin\\{)(?=[\\w\\:\\-]+(?:(?:\\s+[\\w\\-:]+(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?)*)\\s*\\/?>|\\/[\\w\\:\\-]+[^>]*\\})",
    "close": "(?<=\\\\end\\{)(?:[\\w\\:\\-]+(?:(?:\\s+[\\w\\-:]+(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^>\\s]+))?)*)\\s*\\/?|\\/[\\w\\:\\-]+[^>]*)(\\})",
    "style": "tag",
    "scope_exclude": ["string", "comment"],
    "language_filter": "whitelist",
    "language_list": ["LaTeX"],
    "plugin_library": "bh_modules.tags",
    "find_in_sub_search": "only",
    "enabled": true
},


and then

Code: Select all
"tag_mode": {
        "xhtml": ["XML", "LaTeX"], ...


But I don't get anything. I haven't been able to find info on how to hook up custom tags.
adamal
 
Posts: 1
Joined: Sat Feb 08, 2014 5:28 pm

PreviousNext

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 7 guests