<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    Andy, thank you very much for your help. <br>
    <br>
    That doesn’t work for me. As I mentioned before, I’m working with
    two CodeArea implementations - JFX and RTFX, <br>
    and CSS is the common styling mechanism. I can’t use code for one
    and CSS for the other. <br>
    <br>
    Well, technically I could, but it just wouldn’t make any sense.<br>
    <br>
    Best regards, Pavel<br>
    <br>
    <div class="moz-cite-prefix">On 5/5/25 22:54, Andy Goryachev wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:BYAPR10MB3013C01179A1F8CA9244D137E58E2@BYAPR10MB3013.namprd10.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator"
        content="Microsoft Word 15 (filtered medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:"Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}@font-face
        {font-family:Aptos;
        panose-1:2 11 0 4 2 2 2 2 2 4;}@font-face
        {font-family:"Iosevka Fixed SS16";
        panose-1:2 0 5 9 3 0 0 0 0 4;}@font-face
        {font-family:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}@font-face
        {font-family:"\@Yu Gothic";
        panose-1:2 11 4 0 0 0 0 0 0 0;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:10.0pt;
        font-family:"Aptos",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Iosevka Fixed SS16";
        color:windowtext;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        mso-ligatures:none;}div.WordSection1
        {page:WordSection1;}</style>
      <div class="WordSection1">
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">You
            have to use highlights for that, since you can't assign CSS
            style to a part of the Text instance, and you can't set a
            background on it.<o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">JDK-8355774
            is pretty high on my list of things to do.</span><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy
            <o:p></o:p></span></p>
        <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""><o:p> </o:p></span></p>
        <div id="mail-editor-reference-message-container">
          <div>
            <div>
              <div
style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
                <p class="MsoNormal" style="margin-bottom:12.0pt"><b><span
                      style="font-size:12.0pt;color:black">From:
                    </span></b><span
                    style="font-size:12.0pt;color:black">openjfx-dev
                    <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev-retn@openjdk.org"><openjfx-dev-retn@openjdk.org></a> on behalf of
                    PavelTurk <a class="moz-txt-link-rfc2396E" href="mailto:pavelturk2000@gmail.com"><pavelturk2000@gmail.com></a><br>
                    <b>Date: </b>Monday, May 5, 2025 at 12:47<br>
                    <b>To: </b><a class="moz-txt-link-abbreviated" href="mailto:openjfx-dev@openjdk.org">openjfx-dev@openjdk.org</a>
                    <a class="moz-txt-link-rfc2396E" href="mailto:openjfx-dev@openjdk.org"><openjfx-dev@openjdk.org></a><br>
                    <b>Subject: </b>Re: CodeArea: -fx-background-color
                    doesn't work.<o:p></o:p></span></p>
              </div>
              <p class="MsoNormal" style="margin-bottom:12.0pt"><span
                  style="font-size:12.0pt">Hello, Andy<br>
                  <br>
                  Yes, I need to add a background color for a text
                  segment within a paragraph using CSS.
                  <br>
                  <br>
                  I have just opened an issue with ID : 9078469.<br>
                  <br>
                  Can anyone give an estimate of when this issue might
                  be addressed? Background color is such a fundamental
                  feature
                  <br>
                  that it's impossible to work without it.<br>
                  <br>
                  Best regards, Pavel<br>
                  <br>
                  <o:p></o:p></span></p>
              <div>
                <p class="MsoNormal"><span style="font-size:12.0pt">On
                    5/5/25 22:09, Andy Goryachev wrote:<o:p></o:p></span></p>
              </div>
              <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
                <div>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Dear
                      Pavel:</span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">Can
                      you clarify what you are trying to do exactly?</span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">If
                      you are trying to add a background to a text
                      segment within the paragraph (as your code seem to
                      indicate), then the only way to do it is to call
                      Builder.addHighlight().</span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">If
                      you are trying to set the background of the whole
                      paragraph, you've hit another missing API similar
                      to JDK-8355774 - there is currently no way to
                      style the paragraphs via CSS.  There is the
                      Builder.setParagraphAttributes(StyleAttributeMap)
                      but a CSS one is missing.</span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16"">-andy</span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <p class="MsoNormal"><span
style="font-size:11.0pt;font-family:"Iosevka Fixed SS16""> </span><o:p></o:p></p>
                  <div id="mail-editor-reference-message-container">
                    <div>
                      <div>
                        <div
style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
                          <p class="MsoNormal"
                            style="margin-bottom:12.0pt"><b><span
                                style="font-size:12.0pt;color:black">From:
                              </span></b><span
                              style="font-size:12.0pt;color:black">openjfx-dev
                              <a
href="mailto:openjfx-dev-retn@openjdk.org" moz-do-not-send="true">
                                <openjfx-dev-retn@openjdk.org></a>
                              on behalf of PavelTurk <a
                                href="mailto:pavelturk2000@gmail.com"
                                moz-do-not-send="true">
                                <pavelturk2000@gmail.com></a><br>
                              <b>Date: </b>Saturday, May 3, 2025 at
                              10:07<br>
                              <b>To: </b><a
                                href="mailto:openjfx-dev@openjdk.org"
                                moz-do-not-send="true"
                                class="moz-txt-link-freetext">openjfx-dev@openjdk.org</a>
                              <a href="mailto:openjfx-dev@openjdk.org"
                                moz-do-not-send="true">
                                <openjfx-dev@openjdk.org></a><br>
                              <b>Subject: </b>CodeArea:
                              -fx-background-color doesn't work.</span><o:p></o:p></p>
                        </div>
                        <div>
                          <p class="MsoNormal"><span
                              style="font-size:11.0pt">For styling CodeArea, I use exclusively style classes, and this is the foundation of my entire architecture.<br>
Today I tried to implement search highlighting (via background color), but it didn't work. Below is my test code.<br>
                              <br>
Can anyone tell me how to set the background color using CSS? For example, in RichTextFX's CodeArea,<br>
                              they have -rtfx-background-color.<br>
                              <br>
public class JfxCodeArea extends Application {<br>
                              <br>
                                   @Override<br>
     public void start(Stage primaryStage) throws Exception {<br>
                                       String text = """<br>
                       Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt<br>
                       ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco<br>
                       laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit<br>
                       in voluptate velit esse cillum dolore eu fugiat nulla pariatur.<br>
                                                     """;<br>
                              <br>
                                       String css = """<br>
                                           .test {<br>
                                               -fx-font-weight: bold;<br>
                                               -fx-fill: red;<br>
                 -fx-background-color: green;<br>
                                           }<br>
                              <br>
                                       """;<br>
                                       String data = <span
                                class="MsoHyperlink"><a class="moz-txt-link-rfc2396E" href="data:text/css;base64,">"data:text/css;base64,"</a></span> + Base64.getEncoder().encodeToString(css.getBytes(StandardCharsets.UTF_8));<br>
                              <br>
         CodeArea codeArea = new CodeArea();<br>
         codeArea.getStylesheets().add(data);<br>
                              <br>
         codeArea.setSyntaxDecorator(new SyntaxDecorator() {<br>
                                           @Override<br>
             public RichParagraph createRichParagraph(CodeTextModel model, int index) {<br>
                 var builder = RichParagraph.builder();<br>
                 builder.addWithStyleNames(model.getPlainText(index), "test");<br>
                                               return builder.build();<br>
                                           }<br>
                              <br>
                                           @Override<br>
             public void handleChange(CodeTextModel m, TextPos start, TextPos end, int charsTop, int linesAdded, int charsBottom) {<br>
                              <br>
                                           }<br>
                                       });<br>
                              <br>
         VBox.setVgrow(codeArea, Priority.ALWAYS);<br>
                                       var button = new Button("Go!");<br>
         button.setOnAction(e -> codeArea.setText(text));<br>
         VBox root = new VBox(codeArea, button);<br>
         Scene scene = new Scene(root, 600, 200);<br>
                                       primaryStage.setScene(scene);<br>
                                       primaryStage.show();<br>
                              <br>
                                   }<br>
                              <br>
     public static void main(String[] args) {<br>
                                       launch(args);<br>
                                   }<br>
                              }<br>
                              <br>
                              Best regards, Pavel</span><o:p></o:p></p>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </blockquote>
              <p class="MsoNormal"><span style="font-size:12.0pt"><o:p> </o:p></span></p>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
  </body>
</html>