-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to set default text color with word highlighting of CodeArea? #442
Comments
If I'm understanding you correctly, you want to do the following, right?
|
So, first i create CodeArea object, set id (style from css file), then I add highlightning
But still all text is colored :( Maybe Im doing something wrong Here highlightning (without style & dark background): I need to color rest of text, i dont have already any ideas how to do that :( |
What happens if you don't set the area's ID? Does the highlighting work then? And what does your |
It works, but default text color is black and dark background need white text or something. (I need dark background so...) computeHighlighting is method from here:
|
Wait, so you're using the |
Only patterns for matcher:
|
It doesn't seem like you're doing anything wrong. Have you debugged it via ScenicView yet? It does seem clear that the initial CSS overrides the highlighting CSS. You will probably need to subclass |
Ok, thanks for help, I will try ;) |
Same here i think, im trying to set the default text color, the highlighting works fine. |
Yeah, but not the text-color, is there maybe a work around for that issue? |
@liz3 After looking at it a bit more, I got the default color to work by using the following CSS file: .styled-text-area {
-fx-background-color: black;
}
.paragraph-box > .paragraph-text > .text {
-fx-fill: white;
} Technically, the CSS should be |
I've updated the CSS Reference Guide to properly demonstrate the three selector usage to style the default text. |
Update: I found that if I replaced the .styled-text-area {
-fx-background-color: black;
}
.styled-text-area .virtual-flow .paragraph-box .paragraph-text .text {
-fx-fill: white;
} Thus, @KnightPL, you can achieve your goal without subclassing the area by using this CSS: #codearea .virtual-flow .paragraph-box .paragraph-text .text {
-fx-fill: whitesmoke;
} |
I've updated CSS Ref Guide to include the full selector string |
Actually... Forget what I said in my previous comment, @KnightPL. Instead, I found that this will work: .styled-text-area {
-fx-background-color: black;
}
#someArea .text {
-fx-fill: white;
}
#someArea .red {
-fx-fill: red;
} and an application like so: import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.fxmisc.flowless.VirtualizedScrollPane;
import org.fxmisc.richtext.CodeArea;
import java.util.Collections;
public class CssBug extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
CodeArea area = new CodeArea("initial text");
VirtualizedScrollPane<CodeArea> vsPane = new VirtualizedScrollPane<>(area);
area.setId("someArea");
area.setStyle(6, area.getLength(), Collections.singleton("red"));
Scene scene = new Scene(vsPane, 500, 200);
scene.getStylesheets().addAll(CssBug.class.getResource("css-bug.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
} I can override the default |
@KnightPL, is this issue resolved? |
@JordanMartinez I run the
So I modified the
It worked, BUT the line numbers became white, too How can I solve this problem ? Thanks~ |
Add a .lineno {
-fx-background-color: black;
} The CSS Reference Guide explains that one can style the |
@JordanMartinez |
I want to color the words which have not yet been colored with word highlightning (patterns etc.)
I tried:
and in .css file
but it colors all text in CodeArea
Any ideas or help ?
Sorry about my bad english :)
Thanks
The text was updated successfully, but these errors were encountered: