Andy, thank you very much for your response. But as I’ve said many times, I’m 
only considering styling through a CSS file.

Best regards, Pavel

On 5/12/25 19:28, Andy Goryachev wrote:

Pavel:

Underlines and strike-through attributes are available via 
StyleAttributeMap.STRIKE_THROUGH and StyleAttributeMap.UNDERLINE (using text 
color).  On the other hand, adding this functionality via addHighlight() would 
allow the application to style the shapes via CSS.

-andy

*From: *openjfx-dev <openjfx-dev-r...@openjdk.org> on behalf of PavelTurk 
<pavelturk2...@gmail.com>
*Date: *Thursday, May 8, 2025 at 22:18
*To: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org>
*Subject: *Re: RFR: 8355774: RichTextArea: provide mechanism for CSS styling of 
highlights

Andy, I'm really glad we figured out the background-color issue, and I'm also 
very grateful to you!

Regarding wavy lines and other types of underlining — in my previous message, I 
listed the key attributes
that are essential for a modern CodeArea. For example, underline for links — I 
don't think it's necessary to write
that the internet is extremely popular today and that links in code are common 
practice, and so on.

Of course, all of these properties should be set via a CSS file, since that's 
the most efficient way to use CSS —
when styling is completely separated from logic.

So, the list contains five properties. If two of them are not supported, that 
means (to me) that only 60% of the
core properties are supported.

That's just my feedback — the decision is, of course, yours :)

Best regards, Pavel

On 5/9/25 00:09, Andy Goryachev wrote:

    The only property that makes sense is the background color.  The wavy and 
other kinds of underlines, while they make some sense in the context of the 
CodeArea, would fail in general in the context of RichTextArea where the 
content may include nodes and images.  The highlights were designed 
specifically for the case to highlight the content range regardless of what is 
in it.

    I've reopened https://bugs.openjdk.org/browse/JDK-8356436 for the 
background color.

    Thank you for your patience and good suggestions!

    -andy

    *From: *openjfx-dev <openjfx-dev-r...@openjdk.org> 
<mailto:openjfx-dev-r...@openjdk.org> on behalf of PavelTurk <pavelturk2...@gmail.com> 
<mailto:pavelturk2...@gmail.com>
    *Date: *Thursday, May 8, 2025 at 13:13
    *To: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org> 
<mailto:openjfx-dev@openjdk.org>
    *Subject: *Re: RFR: 8355774: RichTextArea: provide mechanism for CSS 
styling of highlights

    Since we’re talking about code styling, I would highlight the following as 
the main properties:
    - foreground color (+)
    - background color (-)
    - font (weight, italic, size, name) (+)
    - underline (e.g. for links) (?)
    - wavy underline (e.g. for spelling) (-)

    I think these properties cover 99% of all the necessary properties for 
CodeArea.
    I used + and - to show what has already been implemented.

    Best regards, Pavel

    On 5/8/25 22:21, Andy Goryachev wrote:

        Oh, I finally get it what you want.  Thanks!

        What you asking is effectively to add support for some additional 
properties to the class that renders the text segment (currently, Text).  My 
first question is - what are the additional properties, beside the 
background-color?  If it's only the background color, it's probably easy to add.

        Anything beyond that, such as equivalent of full -fx-region-background 
or -fx-region-border, would be extremely unlikely.

        -andy

        *From: *openjfx-dev <openjfx-dev-r...@openjdk.org> 
<mailto:openjfx-dev-r...@openjdk.org> on behalf of PavelTurk <pavelturk2...@gmail.com> 
<mailto:pavelturk2...@gmail.com>
        *Date: *Thursday, May 8, 2025 at 11:44
        *To: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org> 
<mailto:openjfx-dev@openjdk.org>
        *Subject: *Re: RFR: 8355774: RichTextArea: provide mechanism for CSS 
styling of highlights

        Andy, thank you for your reply.

        I have already provided some examples, but I’ll give one more very 
simple example that clearly illustrates the problem.

        I have a library that uses JFX CodeArea. Naturally, all styles are 
stored in a CSS file. Users of this library can customize
        how the code is displayed by modifying the styles in the CSS file. 
Let’s take the search feature as an example. In the
        CSS file, there is a class:

        .search-match {
            -fx-background-color: orange;
        }

        But the user wants to change not the background color, but the 
foreground color and font weight. So they write:

        .search-match {
            -fx-fill: orange;
            -fx-font-weight: bold;
        }

        And this should work. If it doesn’t, then it’s no longer CSS-based 
styling.

        If, for some reason, the -fx-background-color property cannot be used, 
an alternative property can be introduced,
        such as -fx-highlight-color. However, everything else in the example 
should work as described.

        Best regards, Pavel

        On 5/8/25 21:25, Andy Goryachev wrote:

            Pavel:

            I think your comments in the ticket are still invisible to me, so I 
can't comment.

            About your recent comment in the PR - I have difficulty understanding what 
you mean. We are not adding methods to "style individual properties".  We are 
adding methods that allow the application to use CSS to style parts of the visual 
representation of the given RichParagraph.

            Perhaps if you describe what kind of visual representation you have 
in mind, we can show how to achieve that in the code.

            -andy

            *From: *openjfx-dev <openjfx-dev-r...@openjdk.org> 
<mailto:openjfx-dev-r...@openjdk.org> on behalf of PavelTurk <pavelturk2...@gmail.com> 
<mailto:pavelturk2...@gmail.com>
            *Date: *Thursday, May 8, 2025 at 11:04
            *To: *openjfx-dev@openjdk.org <openjfx-dev@openjdk.org> 
<mailto:openjfx-dev@openjdk.org>
            *Subject: *Re: RFR: 8355774: RichTextArea: provide mechanism for 
CSS styling of highlights

            I am not a member of the JavaFX team, but if I may, I’d like to 
express my opinion. I believe that creating separate
            methods for styling individual properties is a very problematic and 
dangerous decision.

            First, the usefulness of such methods is minimal because when 
styling is done via CSS, the assumption is that
            adjusting the CSS file should be sufficient—something that won’t 
work in this case. For example one user for search
            result wants to set background color for matches but another one 
wants to set foreground color + weight.
            Second, it violates fundamental CSS principles. Third, if these 
methods are added to the API, they cannot later
            be removed without breaking backward compatibility.

            I wrote about this in detail in the additional information for 
JDK-8356436, but my comment has not yet been approved
            by a moderator.

            When in doubt, it’s very helpful to see how others are doing it. In 
RichTextFX, special CSS properties were introduced,
            which resulted in a consistent standard for applying CSS styles to 
all properties—fully aligned with established CSS norms.

            This is my personal opinion, which, of course, can be wrong.

            Best regards, Pavel

            On 5/8/25 20:46, Andy Goryachev wrote:
            > Adding missing APIs related to styling the highlights with CSS:
            >
            > ![Screenshot 2025-05-07 at 15 08 
53](https://github.com/user-attachments/assets/e37062b4-9804-40a7-872d-830fe0f584c1)
            >
            >
            >
            > Adds methods to the `RichParagraph.Builder`:
            >
            >
            >          /**
            >           * Adds a wavy underline (typically used as a spell 
checker indicator) with the specified style name(s).
            >           * <p>
            >           * The corresponding styles should define CSS properties 
applicable to {@link javafx.scene.shape.Path}.
            >           *
            >           * @param start the start offset
            >           * @param length the end offset
            >           * @param css the style name(s)
            >           * @return this {@code Builder} instance
            >           * @since 25
            >           */
            >          public Builder addWavyUnderline(int start, int length, 
String ... css) {
            >
            >
            >
            >          /**
            >           * Adds a highlight with the specified style name(s).
            >           * Use translucent colors to enable multiple highlights 
in the same region of text.
            >           * <p>
            >           * The corresponding styles should define CSS properties 
applicable to {@link javafx.scene.shape.Path}.
            >           *
            >           * @param start the start offset
            >           * @param length the end offset
            >           * @param css the style name(s)
            >           * @return this {@code Builder} instance
            >           * @since 25
            >           */
            >          public Builder addHighlight(int start, int length, 
String ... css) {
            >
            >
            >
            > Also adding similar methods to the `SimpleViewOnlyStyledModel` 
class:
            >
            >
            >      /**
            >       * Adds a highlight of the given color to the specified 
range within the last paragraph,
            >       * with the specified style name(s).
            >       *
            >       * @param start the start offset
            >       * @param length the length of the highlight
            >       * @param css the highlight style name(s)
            >       * @return this model instance
            >       * @since 25
            >       */
            >      public SimpleViewOnlyStyledModel highlight(int start, int 
length, String ... css) {
            >
            >
            >      /**
            >       * Adds a wavy underline (typically used as a spell checker 
indicator)
            >       * to the specified range within the last paragraph, with 
the specified style name(s).
            >       *
            >       * @param start the start offset
            >       * @param length the length of the highlight
            >       * @param css the highlight style name(s)
            >       * @return this model instance
            >       * @since 25
            >       */
            >      public SimpleViewOnlyStyledModel addWavyUnderline(int start, 
int length, String ... css) {
            >
            > -------------
            >
            > Commit messages:
            >   - tab
            >   - css
            >
            > Changes: https://git.openjdk.org/jfx/pull/1802/files
            >    Webrev: https://webrevs.openjdk.org/?repo=jfx&pr=1802&range=00 
<https://webrevs.openjdk.org/?repo=jfx&pr=1802&range=00>
            >    Issue: https://bugs.openjdk.org/browse/JDK-8355774
            >    Stats: 128 lines in 4 files changed: 110 ins; 8 del; 10 mod
            >    Patch: https://git.openjdk.org/jfx/pull/1802.diff
            >    Fetch: git fetch https://git.openjdk.org/jfx.git 
pull/1802/head:pull/1802
            >
            > PR: https://git.openjdk.org/jfx/pull/1802

Reply via email to