Line Spacing

Questions on using RSyntaxTextArea should go here.

Moderator: robert

Line Spacing

Postby tekpyx » Wed Feb 17, 2010 5:56 pm

I wonder if it would be possible to support line spacing in RSTA.
This would be very useful for my type of documents.
Serge
tekpyx
 
Posts: 2
Joined: Wed Feb 03, 2010 11:22 pm

Re: Line Spacing

Postby robert » Thu Feb 18, 2010 2:01 pm

Should be easy enough to add. How should the API look? Do you want to specify extra space between lines? In pixels? Or is specifying the line height (as opposed to extra space) more natural? In the latter case I suppose lines would just overlap if the line height was made too small. So my guess would be an API for extra spacing between lines?
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Line Spacing

Postby tekpyx » Thu Feb 18, 2010 3:21 pm

Extra spacing in pixels would be perfect.
Thank you very much !
tekpyx
 
Posts: 2
Joined: Wed Feb 03, 2010 11:22 pm

Re: Line Spacing

Postby kenston » Tue Apr 27, 2010 4:59 am

Hi!

May I know the status of this method?

Is it present in the latest release?

Thank you.
kenston
 
Posts: 8
Joined: Sat Dec 19, 2009 4:32 am

Re: Line Spacing

Postby robert » Tue Apr 27, 2010 8:34 pm

I took a look at this, and it turns out that while it sounds simple, it's harder to implement than I thought.

One temporary (but nasty) work-around is to set one one of your token styles that isn't used in the languages you edit to something larger than the rest. Since RSTA makes all lines the same height (the height of the largest font in all token types), you could probably set some unused Token type to use a Font of just the right point size. For example,

Code: Select all
SyntaxScheme scheme = textArea.getSyntaxScheme();
Style unusedStyle = new Style(Color.black, null, new Font("Monospaced", Font.PLAIN, 32));
scheme.setStyle(Token.LITERAL_BACKQUOTE, style);
textArea.setSyntaxScheme((SyntaxScheme)scheme.clone());


Assuming the language being edited doesn't highlight backtick literals (e.g. `foobar`), this will have the nice side effect of making all lines taller than the fonts being used for all other tokens. Naturally, if your language has backtick literals, you'd have to pick some other token type to modify in this way. For non-markup programming languages, Token.MARKUP_TAG_NAME might be another good choice.

Again, this is such a bad workaround that I almost am ashamed to suggest it. But, maybe it's good enough for you, at least until official support gets added!
User avatar
robert
 
Posts: 797
Joined: Sat May 10, 2008 5:16 pm

Re: Line Spacing

Postby kenston » Wed Apr 28, 2010 4:17 am

Thank you!
kenston
 
Posts: 8
Joined: Sat Dec 19, 2009 4:32 am


Return to Help

Who is online

Users browsing this forum: Yahoo [Bot] and 5 guests