We use the CodeArea in JabRef as text-editor for BibTeX sources. I was working on a highlighting parser when I noticed, that somehow org.fxmisc.richtext.GenericStyledArea#setStyle(int, int, S) doesn't work. I can use setStyle for the whole text successfully, but as soon as I try to style only a text-range, nothing is changed. I've created a minimal example that is based on the java-keywords code and can be run on its own (adjust the package header).
There, I try to set the style for testing. The commented portion works, the text-range styling not
@Override
public void start(Stage primaryStage) {
CodeArea codeArea = new CodeArea();
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
codeArea.replaceText(0, 0, sampleCode);
// codeArea.setStyle("-fx-font-weight: bold");
codeArea.setStyle(0,30, Collections.singleton("-fx-font-weight: bold"));
Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(codeArea)), 600, 400);
primaryStage.setScene(scene);
primaryStage.setTitle("Java Keywords Demo");
primaryStage.show();
}
I'm on Linux with Java 1.8.0_144 and richtextfx:0.8.1. Is this supposed to work this way or am I doing something completely stupid?
We use the
CodeAreain JabRef as text-editor for BibTeX sources. I was working on a highlighting parser when I noticed, that somehoworg.fxmisc.richtext.GenericStyledArea#setStyle(int, int, S)doesn't work. I can usesetStylefor the whole text successfully, but as soon as I try to style only a text-range, nothing is changed. I've created a minimal example that is based on the java-keywords code and can be run on its own (adjust the package header).There, I try to set the style for testing. The commented portion works, the text-range styling not
I'm on Linux with Java 1.8.0_144 and richtextfx:0.8.1. Is this supposed to work this way or am I doing something completely stupid?