RFR: 8301121: RichTextArea Control (Incubator)

Andy Goryachev angorya at openjdk.org
Wed Aug 14 18:29:55 UTC 2024


On Wed, 14 Aug 2024 14:43:54 GMT, Robert Lichtenberger <rlichten at openjdk.org> wrote:

>> Incubating a new feature - rich text control, **RichTextArea**, intended to bridge the functional gap with Swing and its StyledEditorKit/JEditorPane. The main design goal is to provide a control that is complete enough to be useful out-of-the box, as well as open to extension by the application developers.
>> 
>> This is a complex feature with a large API surface that would be nearly impossible to get right the first time, even after an extensive review. We are, therefore, introducing this in an incubating module, **jfx.incubator.richtext**. This will allow us to evolve the API in future releases without the strict compatibility constraints that other JavaFX modules have.
>> 
>> Please check out two manual test applications - one for RichTextArea (**RichTextAreaDemoApp**) and one for the CodeArea (**CodeAreaDemoApp**). Also, a small example provides a standalone rich text editor, see **RichEditorDemoApp**.
>> 
>> Because it's an incubating module, please focus on the public APIs rather than implementation.  There **will be** changes to the implementation once/if the module is promoted to the core by popular demand.  The goal of the incubator is to let the app developers try the new feature out. 
>> 
>> **References**
>> 
>> - Proposal: https://github.com/andy-goryachev-oracle/Test/blob/main/doc/RichTextArea/RichTextArea.md
>> - Discussion points: https://github.com/andy-goryachev-oracle/Test/blob/main/doc/RichTextArea/RichTextAreaDiscussion.md
>> - API specification (javadoc): https://cr.openjdk.org/~angorya/RichTextArea/javadoc
>> - RichTextArea RFE: https://bugs.openjdk.org/browse/JDK-8301121
>> - Behavior doc: https://github.com/andy-goryachev-oracle/jfx/blob/8301121.RichTextArea/doc-files/behavior/RichTextAreaBehavior.md
>> - CSS Reference: https://cr.openjdk.org/~angorya/RichTextArea/javadoc/javafx.graphics/javafx/scene/doc-files/cssref.html
>> - InputMap (v3): https://github.com/andy-goryachev-oracle/Test/blob/main/doc/InputMap/InputMapV3.md
>> - Previous Draft PR: https://github.com/openjdk/jfx/pull/1374
>
> modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/SyntaxDecorator.java line 37:
> 
>> 35:     /**
>> 36:      * Creates a {@link RichParagraph} from the paragraph plain text.
>> 37:      * The text string is guaranteed to contain neither newline nor carriage return symbols.
> 
> Comment seems unclear to me. Which text string ? There is no String parameter here, only a CodeTextModel with a paragraph index...

Hmmm.  How about

Creates a {@link RichParagraph} from the paragraph plain text **string**.
The text string is guaranteed to contain neither newline nor carriage return symbols.

?

> modules/jfx.incubator.richtext/src/main/java/jfx/incubator/scene/control/richtext/model/BasicTextModel.java line 198:
> 
>> 196:      */
>> 197:     public static class InMemoryContent implements Content {
>> 198:         private final ArrayList<String> paragraphs = new ArrayList<>();
> 
> Since paragraphs may be inserted anywhere, I would guess that using a LinkedList should be more efficient here. Otherwise, when adding a line break somewhere in the middle of a long text, a lot of array members must be copied.

You are right, but this is just a default implementation.  you can still implement your own `BasicTextModel.Content` and pass it to the constructor.

Do you want to see an in-memory implementation optimized for large number of paragraphs or should it better be left up to the app developers?

-------------

PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1717383475
PR Review Comment: https://git.openjdk.org/jfx/pull/1524#discussion_r1717382025


More information about the openjfx-dev mailing list