tabbed lines

Post a reply

Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:
BBCode is ON
[img] is ON
[flash] is OFF
[url] is ON
Smilies are ON
Topic review
   

Expand view Topic review: tabbed lines

Re: tabbed lines

Post by robert » Wed Jun 29, 2011 2:08 am

Hi Remco,

This is a good point. You don't actually have to modify the code to get this behavior though - just call:

Code: Select all
textArea.setClearWhitespaceLinesEnabled(false);


and all-whitespace lines will be kept around.

Re: tabbed lines

Post by Remco » Tue May 10, 2011 4:53 pm

First of all, because i'm new to the forum, let me say thank you for this great component, It's one of my favourites!

I've been playing around with this new feature and I really like it. A possible improvement I would like to suggest has to do with the auto indentation. When pressing enter multiple times the indentation on the previous (blank) line is removed and this causes gaps in the tab lines. Just for testing I removed the following:
Code: Select all
if (leadingWS.length()==len &&
      sta.isClearWhitespaceLinesEnabled()) {
   // If the line was nothing but whitespace, select it
   // so its contents get removed.
   sta.setSelectionStart(start);
   sta.setSelectionEnd(end);
}

from the method 'insertNewlineWithAutoIndent' in 'RSyntaxTextAreaEditorKit'.
Personally I prefer this behaviour because I frequently leave blank lines between code blocks.

Just a little idea I thought I'd share.

Best regards,
Remco

Re: tabbed lines

Post by robert » Sat Apr 30, 2011 7:41 pm

I've updated RSTA to somewhat improve the tab line painting. Please grab the latest and try things again.

It might be cool if the TokenMaker has methods like isWhitespace(int type) and isSeparator(int type) to allow a little more flexibility.


Might be a good idea. For now, the latest update no longer requires Token.WHITESPACE to paint tab lines; it'll do so with any token type, so you now get them within multi-line comments, Token.IDENTIFIER (if you were to match all "plain text" and whitespace together for performance, for example), or whatever else you throw at it. If the token type isn't Token.WHITESPACE, it'll paint tab lines in the right places for all leading whitespace in the first token of a line, if any. If it IS Token.WHITESPACE though, it'll assume the token really is all spaces and tabs, and skip the scan for leading whitespace for performance reasons (all the built-in scanners use Token.WHITESPACE the "expected" way).

This does mean that, if you use your own token types and not RSTA's, if you have a type with the same value as Token.WHITESPACE, you might get tab lines painted where you wouldn't expect them to be (inside text, etc.). But this is somewhat unlikely, and the workaround would be to simply change that particular token type to a different value, so it would be an easy fix.

I can reproduce your rendering issue in your app, but not in mine with the latest changes (and using the same font as you). Can you update and see if that fixes things (not sure why it would as the actual rendering code hasn't changed, but just to make sure)? If it's still happening, I'll really buckle down and figure it out.

There also might be third round of updates, redoing how these lines are painted, since the current implementation doesn't paint them at all on lines with no tokens on them, which is different, and (albeit slightly) annoying compared to what Scite does.

Re: tabbed lines

Post by 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

Re: tabbed lines

Post by 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

Re: tabbed lines

Post by 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.

Re: tabbed lines

Post by Guest » Fri Apr 22, 2011 7:08 am

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

Re: tabbed lines

Post by 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.

Re: tabbed lines

Post by 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

Re: tabbed lines

Post by 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.

Top