tabbed lines

General Discussion on RSyntaxTextArea.

Moderator: robert

tabbed lines

Postby Nate » Thu Apr 07, 2011 7:12 am

Does RSyntaxTextArea support tab lines, like SciTE? Eg:

Image

The lines also highlight if your cursor is on a brace at that indentation level and there is a matching brace.
Nate
 
Posts: 15
Joined: Fri Dec 04, 2009 6:45 am

Re: tabbed lines

Postby robert » Thu Apr 07, 2011 2:51 pm

The lines themselves will be quick 'n easy to add (in fact, I'm pretty sure the code's already in there somewhere, but I never finalized it). Having them highlight when you're on a closing brace will be a tad more work, but this kind of stuff is the thing I love, so I'll definitely look into it!

RSTA development has been frozen for a couple of weeks due to an extreme level of stress at work, but I'll get to this as soon as I can.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: tabbed lines

Postby Nate » Thu Apr 07, 2011 8:21 pm

Sweet! I find the lines really help. The highlighting is very cool but only occasionally useful.
Nate
 
Posts: 15
Joined: Fri Dec 04, 2009 6:45 am

Re: tabbed lines

Postby robert » Mon Apr 18, 2011 2:29 pm

Try grabbing the latest from SVN. Call

Code: Select all
textArea.setTabLines(true);


to draw the dotted line at tab stops in whitespace tokens. Forgot to add the ability to change its color, I'll add that later though.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: tabbed lines

Postby Nate » Tue Apr 19, 2011 12:01 am

Cool! I updated, but don't see tab lines. I also don't see matching braces, not sure if that is related? Any ideas? Code is here (TableLayoutEditor has the RSyntaxTextArea):
http://code.google.com/p/table-layout/s ... ut%2Fswing
Nate
 
Posts: 15
Joined: Fri Dec 04, 2009 6:45 am

Re: tabbed lines

Postby robert » Wed Apr 20, 2011 4:00 pm

Hmm. I'll look again, but it's working for me. I'll try uploading a new RSTA example applet with the option available, to see if you can see it in the applet. Then we'd know whether it's your crappy code or mine. :)

Also, when you say "I also don't see any matching braces," do you mean that the standard "bracket matching" feature isn't working for you, or something to do with your request for the relevant dots to highlight when your caret is at a bracket? The latter I haven't considered yet; RSTA doesn't currently retain enough state information to do such a thing for arbitrary languages at the moment, I don't think.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: tabbed lines

Postby Guest » Fri Apr 22, 2011 7:08 am

I meant the standard bracket matching doesn't occur in my app.
Guest
 

Re: tabbed lines

Postby robert » Sat Apr 23, 2011 12:38 am

Change RagelTokenMaker to extend "public boolean getCurlyBracesDenoteCodeBlocks()" to return true. That will solve your bracket matching problem. If my wife will let me have some time to be introverted this weekend, I'll dig into the tab line painting.
User avatar
robert
 
Posts: 774
Joined: Sat May 10, 2008 5:16 pm

Re: tabbed lines

Postby Guest » Sat Apr 23, 2011 10:10 pm

RagelTokenMaker is a base class I use for convenience when using Ragel with RSyntaxTextArea. The class that my app actually uses for tokens is TableLayoutTokenizer. It is hard to read because most of it is code generated from this much easier to read file, but (at the bottom) I already have getCurlyBracesDenoteCodeBlocks returning true.

I dug into it a little and found that RSyntaxUtilities.getMatchingBracketPosition only works if the bracket is a Token.SEPARATOR. I changed my TableLayoutTokenizer to use Token.SEPARATOR and it does indeed work. However, I match parenthesis and square bracket with different token types because I want to color them differently. I also would like pointy brackets to be matched. I went ahead and modified getMatchingBracketPosition to do what I need for now.

This is probably the same problem with my tab lines. I'm using my own token types, but I see now that RSyntaxTextArea assumes I will use its token types (eg, Token.NUM_TOKEN_TYPES). I rearranged my parsing to differentiate from plain text and whitespace, then I used Token.WHITESPACE for whitespace, and now I have tab lines. :) Note sure what else gets messed up by using my own token types.

It might be cool if the TokenMaker has methods like isWhitespace(int type) and isSeparator(int type) to allow a little more flexibility. It hasn't needed it, since adding support for a new language is so hard with JFlex. The Ragel way of parsing is really sweet. :)

You can see my app running here:
http://table-layout.googlecode.com/svn/ ... or.jnlp?12
Guest
 

Re: tabbed lines

Postby Guest » Sat Apr 23, 2011 10:13 pm

When I move the cursor through tab lines, I notice they are drawn a little strange:

Image
Guest
 

Next

Return to Open Discussion

Who is online

Users browsing this forum: No registered users and 5 guests

cron