-
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
Any efficient way to setStyle for multiple positions? #1177
Comments
I think I have found the suitable demo for this question. I should have set a kind of observer to observe the changes before setting the text to the textarea. I would suggest that it is better to add some explanation for StyleSpans how it works. And from the word However, I do not understand the differences between these two implementations. textArea.multiPlainChanges()
.successionEnds(Duration.ofMillis(500))
.subscribe(change -> {
textArea.setStyleSpans(0, computeHighlighting(textArea.getText()));
}); codeArea.getVisibleParagraphs().addModificationObserver
(
new VisibleParagraphStyler<>( codeArea, this::computeHighlighting )
); Any pros & cons for these two implementations? How to choose? |
When I was looking at StyleSpans this morning I also thought: this needs better documentation. :-) With regards to the two implementations: |
I am using setStyleClass of StyleClassedTextArea to make colors in a long text paragraph. I have different colors to apply to different words.
Say classNames
style-1
is red,style-2
is blue,style-3
is green.If i want to apply style-1 to multiple sections of the textarea, I need to run them as a loop.
I find it is slow. I guess it is due to it renders every time I applied the styleclass. I tried to set it invisible first but in vain.
Any way to make the rendering more efficient?
or any
batchEditStart()
,batchEditEnd()
for styling? So it will not immediately render before I set all style-1, style-2, style-3The text was updated successfully, but these errors were encountered: