draw2d TextExample.java [message #64302] |
Tue, 11 February 2003 16:21  |
Eclipse User |
|
|
|
In the TextExample, it has an example to render source code.
I am wonder what is the best way to implement color syntaxing when use that
to render source code.
I am thinking I can scan the content to look for key words and create a
number of TextFlow objects for text before the keyword, the keyword itself
and text after the keyword. And then set the font of each TextFlow
accordingly.
Is there a better approach than this? My concern is performance, since I
need to create a lot of small TextFlow objects.
Thank for any feedback.
|
|
|
|
|
Re: draw2d TextExample.java [message #64369 is a reply to message #64347] |
Tue, 11 February 2003 17:07  |
Eclipse User |
|
|
|
Originally posted by: none.us.ibm.com
only for monospace fonts :-)
"Hal" <otaconss2@hotmail.com> wrote in message
news:b2bqch$l16$1@rogue.oti.com...
> what if I need to Bold and use a different color for keywords (same as
JDT),
> will your approach works too?
>
> Thanks.
>
> "Randy Hudson" <none@us.ibm.com> wrote in message
> news:b2bq79$kta$1@rogue.oti.com...
> > There is probably a lighterweight approach. If you know that you are
> going
> > to use the same font, and only change the color, you could use a single
> > TextFlow. The subclass could store highlight regions, and override
> > paintFigure() to break up the text into its regions. This is similar to
> how
> > the JDT does it.
> >
> > "Hal" <otaconss2@hotmail.com> wrote in message
> > news:b2bo33$j1l$1@rogue.oti.com...
> > > In the TextExample, it has an example to render source code.
> > > I am wonder what is the best way to implement color syntaxing when use
> > that
> > > to render source code.
> > >
> > > I am thinking I can scan the content to look for key words and create
a
> > > number of TextFlow objects for text before the keyword, the keyword
> itself
> > > and text after the keyword. And then set the font of each TextFlow
> > > accordingly.
> > >
> > > Is there a better approach than this? My concern is performance, since
I
> > > need to create a lot of small TextFlow objects.
> > >
> > > Thank for any feedback.
> > >
> > >
> >
> >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02989 seconds