Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » e(fx)clipse » Standalone StyledTextArea(Implementing a standalone StyledTextArea for a code editor)
Standalone StyledTextArea [message #1469610] Tue, 11 November 2014 19:14 Go to next message
Guillermo Cifuentes is currently offline Guillermo CifuentesFriend
Messages: 3
Registered: November 2014
Junior Member
Hi!

So we are implementing a code editor which needs to feature inline completion (show with a different opacity the text next to the caret), placeholder editing (complete some syntax and leave some placeholders so the user can tab across them) and syntax highlighting.

I've cloned the efxclipse project and incorporated into the project the sources for StyledTextArea. The issue at the moment is with the content. There's a DefaultContent implementation of StyledTextContent but the main one is done by SWT text classes and an adapter.

I'd prefer not to include these as they have other SWT dependencies and we're using just JavaFX, not JFace neither other SWT components.

Ultimately we'd strip only the necessary classes but there's lots of features we'd not need, so we'd prefer to have a custom lightweight implementation.

What do you recommend us to implement an StyledTextContent given we'd need to implement on top of it the above features?

Thank you very much,
Guillermo
Re: Standalone StyledTextArea [message #1470265 is a reply to message #1469610] Wed, 12 November 2014 07:53 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

On 12.11.14 00:56, Guillermo Cifuentes wrote:
> Hi!
>
> So we are implementing a code editor which needs to feature inline
> completion (show with a different opacity the text next to the caret),
> placeholder editing (complete some syntax and leave some placeholders so
> the user can tab across them) and syntax highlighting.

Ok we have not yet worked on auto-complete, syntax highlighting is
working good. Only mention this because you need to prepare yourself for
some work ;-)

>
> I've cloned the efxclipse project and incorporated into the project the
> sources for StyledTextArea. The issue at the moment is with the content.
> There's a DefaultContent implementation of StyledTextContent but the
> main one is done by SWT text classes and an adapter.

Yeah DefaultContent is not really working - I should fix or better
remove it!

>
> I'd prefer not to include these as they have other SWT dependencies and
> we're using just JavaFX, not JFace neither other SWT components.
>
> Ultimately we'd strip only the necessary classes but there's lots of
> features we'd not need, so we'd prefer to have a custom lightweight
> implementation.


We did this job already for you. In your cloned repo in
"efxclipse/experimental/compensator" you will find:
* org.eclipse.fx.text
* org.eclipse.fx.text.ui

which are forks from their jface-counter parts the only library you
consume directly from Eclipse.org is org.eclipse.text

>
> What do you recommend us to implement an StyledTextContent given we'd
> need to implement on top of it the above features?

I would recommend to use the org.eclipse.text infrastructure because it
already does all parsing and highlighting stuff for you with minimal deps.

IIRC they are:
* org.eclipse.text
* org.eclipse.core.commands
* org.eclipse.equinox.common
* com.ibm.icu.base

If you take a closer look into compensator you'll find out that it is a
fullblown editor framework for fairly any language (currently only
outline support is there but auto-complete is on the list for the
future) but I guess the above should get you going.

The editor framework is more of a research project - just to warn you ;-)

Tom
Re: Standalone StyledTextArea [message #1470905 is a reply to message #1470265] Wed, 12 November 2014 18:27 Go to previous messageGo to next message
Guillermo Cifuentes is currently offline Guillermo CifuentesFriend
Messages: 3
Registered: November 2014
Junior Member
Hi Tom,

First of all thanks a lot for your prompt and extensive response, I appreciate it.

I've been digging into the eclipse text project and I've finally discarded it because it is quite complex, and it could take some time to grok everything and get up to speed.

Since we already have the parsing and tokenizing done with Antlr4, and although it's possible to glue everything together, it required much effort.

What I'm finally doing at the moment is stripping out to the bare bones your editor, since I only need one line, and implementing on top of it the other features.

It's served as a great source of inspiration, the only pity is that I won't be able to contribute back the code since it differs a lot.

Again, thanks you very much and keep up rocking eclipse with JavaFX goodies Smile

Regards,
Guillermo
Re: Standalone StyledTextArea [message #1471069 is a reply to message #1470905] Wed, 12 November 2014 21:31 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

On 12.11.14 19:27, Guillermo Cifuentes wrote:
> Hi Tom,
>
> First of all thanks a lot for your prompt and extensive response, I
> appreciate it.
>
> I've been digging into the eclipse text project and I've finally
> discarded it because it is quite complex, and it could take some time to
> grok everything and get up to speed.
>
> Since we already have the parsing and tokenizing done with Antlr4, and
> although it's possible to glue everything together, it required much
> effort.

Sounds like an cool piece of source.

>
> What I'm finally doing at the moment is stripping out to the bare bones
> your editor, since I only need one line, and implementing on top of it
> the other features.

Maybe you can use the DefaultDocumentAdapter and the IDocument API so
that only the StyleRange stuff is left. Anyways I'm glad the code helps you!

>
> It's served as a great source of inspiration, the only pity is that I
> won't be able to contribute back the code since it differs a lot.
>

No worries - maybe you can contribute to the editor control itself -
e.g. selection is not 100% working.

If there are any interfaces we could add so that you can plug in your
stuff into compensator just file bugs!

Like I said the compensator is more of a cool research project I work on
when I need a break from real world projects ;-)

Tom
Re: Standalone StyledTextArea [message #1494385 is a reply to message #1469610] Mon, 01 December 2014 12:30 Go to previous messageGo to next message
Rodolfo M. Raya is currently offline Rodolfo M. RayaFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,

I'm also trying to use StyledTextArea in one of my projects and am fighting with the code.

The implementation of DefaultContent nested in StyledTextArea is too complex and doesn't seem to work.

The attached file is the simplest implementation of StyledTextContent interface that I could make.

I have a very simple javaFX test application that displays a StyledTextArea on a StackedPane. The StyledTextArea component is not displaying the text at this moment but using the debugger I can see that my custom content provider is working.

Any help in making StyledTextArea work would be appreciated.

Regards,
Rodolfo M. Raya
Re: Standalone StyledTextArea [message #1494434 is a reply to message #1494385] Mon, 01 December 2014 13:18 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

Yes the DefaultContent is broken.

Tom

On 01.12.14 13:30, Rodolfo M. Raya wrote:
> Hi,
>
> I'm also trying to use StyledTextArea in one of my projects and am fighting with the code.
>
> The implementation of DefaultContent nested in StyledTextArea is too complex and doesn't seem to work.
>
> The attached file is the simplest implementation of StyledTextContent interface that I could make.
>
> I have a very simple javaFX test application that displays a StyledTextArea on a StackedPane. The StyledTextArea component is not displaying the text at this moment but using the debugger I can see that my custom content provider is working.
>
> Any help in making StyledTextArea work would be appreciated.
>
> Regards,
> Rodolfo M. Raya
>
Re: Standalone StyledTextArea [message #1494462 is a reply to message #1494434] Mon, 01 December 2014 13:48 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6651
Registered: July 2009
Senior Member
Hi,

I think your display problem is a problem of the StyledTextControl
itself who currently expects the full size of the text to be covered by
StyleRanges.

This works for me:

> BorderPane p = new BorderPane();
> StyledTextArea t = new StyledTextArea();
> t.getStylesheets().add(getClass().getResource("test.css").toExternalForm());
> t.getContent().setText("This is a styled text!");
> t.setStyleRanges(
> new StyleRange[] {
> new StyleRange("text-normal",0,10,null,null),
> new StyleRange("text-highlight",10,12,null,null)
> });
> p.setCenter(t);
>
> Scene scene = new Scene(p,800,600);
>
> primaryStage.setScene(scene);
> primaryStage.show();

test.css:
---------
> .text-normal {
>
> }
>
> .text-highlight {
> -styled-text-color: #ff0000;
> }




Tom

On 01.12.14 14:18, Tom Schindl wrote:
> Hi,
>
> Yes the DefaultContent is broken.
>
> Tom
>
> On 01.12.14 13:30, Rodolfo M. Raya wrote:
>> Hi,
>>
>> I'm also trying to use StyledTextArea in one of my projects and am fighting with the code.
>>
>> The implementation of DefaultContent nested in StyledTextArea is too complex and doesn't seem to work.
>>
>> The attached file is the simplest implementation of StyledTextContent interface that I could make.
>>
>> I have a very simple javaFX test application that displays a StyledTextArea on a StackedPane. The StyledTextArea component is not displaying the text at this moment but using the debugger I can see that my custom content provider is working.
>>
>> Any help in making StyledTextArea work would be appreciated.
>>
>> Regards,
>> Rodolfo M. Raya
>>
>
Re: Standalone StyledTextArea [message #1494523 is a reply to message #1494462] Mon, 01 December 2014 14:47 Go to previous messageGo to next message
Rodolfo M. Raya is currently offline Rodolfo M. RayaFriend
Messages: 18
Registered: July 2009
Junior Member
Thanks Tom.

Your example displays the text but crashes as soon as I press a key. Will try to adapt it with my custom content handler and report what happens.

Regards,
Rodolfo
Re: Standalone StyledTextArea [message #1494614 is a reply to message #1494523] Mon, 01 December 2014 16:10 Go to previous message
Rodolfo M. Raya is currently offline Rodolfo M. RayaFriend
Messages: 18
Registered: July 2009
Junior Member
With my own content handler I can press keys and use the arrows to move the caret but the display is not updated.

Regards,
Rodolfo
Previous Topic:JavaFX classes not resolved after product export
Next Topic:Table column and composition relation binding
Goto Forum:
  


Current Time: Thu Apr 25 21:15:47 GMT 2024

Powered by FUDForum. Page generated in 0.03264 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top