Arbitrary colors management

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: Arbitrary colors management

Re: Arbitrary colors management

Post by robert » Fri May 31, 2013 1:00 pm

That's correct, that is not currently possible, and it is not currently a priority.

Re: Arbitrary colors management

Post by beta-decay » Wed May 29, 2013 10:04 pm

Thank you, I'll look into these classes. Also, I saw here and there on the forum mentions of possibly implementing an on-the-fly method of adding tokens to the current TokenMarker. As I understand, this has not yet happened?

Re: Arbitrary colors management

Post by robert » Wed May 29, 2013 12:36 pm

If you don't keep track of the information yourself, you have to use textArea.getHighlighter().getHighlights() to see what is rendered with a Highlight.

You can't change the foreground color used for specific regions of text without writing your own TokenMaker class. This is because RSyntaxTextArea is built on JTextArea, which doesn't support multiple fonts or colors. RSTA adds this ability by providing its own View implementation, but that View only grabs font & color information from the current TokenMaker.

Re: Arbitrary colors management

Post by beta-decay » Wed May 29, 2013 8:44 am

Sweet, thanks!

Is there a way to retrieve this information back from textArea? I mean which parts of text are which color.
And is there such a mechanism for modifying text color? That's the thing I'm most interested in...

Re: Arbitrary colors management

Post by robert » Tue May 28, 2013 10:58 pm

Not using the mechanisms RSTA uses to syntax highlight text, but you can simulate background colors by using the standard Swing Highlighter class. For example:

java code:

DefaultHighlighter.DefaultHighlightPainter myHighlightPainter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 240, 240));
textArea.getHighlighter().addHighlight(startOffs, endOffs, myHighlightPainter);

Arbitrary colors management

Post by beta-decay » Tue May 28, 2013 5:48 pm

Is it possible, using SyntaxConstants.SYNTAX_STYLE_NONE to liven the document up a bit, changing color/background for an arbitrary piece of text withing the pane?

Top