question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Post append Stylespans

See original GitHub issue

Hey there, i have another question. But first: RichTextFX is a awesome Library and its amazing what you can do with it!

Im my Program, i am doing highlighting the same way as the JavaKeyWord Demo: https://github.com/FXMisc/RichTextFX/blob/master/richtextfx-demos/src/main/java/org/fxmisc/richtext/demo/JavaKeywords.java

Now my question, i want afterwards to add a background color to a line. And i only have the line Number. I tried to get the spans with GenericStyleArea#getStyleSpans(int paragraph) and then append it with the StyleSpans#append method, sadly this did not work at all, after i saw that the append method is returning the spans, i tried to re set these spans to the paragraph in the area, sadly also didnt work(infact there was a case where i ran into a stackoverflow Exception).

So my question: What is the proper way to add style to a specific line with style spans. (If i missed the point in the Documentation which explains that, i would be very happy if you could provide me with a link to it).

Regards Liz3

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:17 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
JordanMartinezcommented, Mar 29, 2018

I’m having some difficulty in understanding what you’re trying to do.

It sounds like, somewhere in the method where you compute the StyleSpans for highlighting, that you would like to overlay another style on top of a section in the StyleSpans object. Is that correct? In other words, you’re not trying to append a style to the end of the StyleSpans object, so that it now is longer than before. You’re trying to do something like the following, which would imply overlay, correct?

text \n text text text text \n text text text
| ----- computed highlighting ---- |
       | background color  | // also add a background color "on top of" the regular styles

Which subclass of GenericStyledArea are you using?

0reactions
JordanMartinezcommented, Apr 2, 2018

Hmm… I started to update the demo to use that and now I’m getting a recursive update like what you described. I’d guess that #695 has potentially introduced a regression.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SpannableStringBuilder to create String with multiple fonts/text ...
First Part Not Bold BOLD rest not bold. You can do this either as @Rajesh suggested or by this. String normalBefore= "First Part...
Read more >
Text Styling With Spans in Android - GeeksforGeeks
In this example, We are going to change the style of text by using the SpannableString class together with StyleSpan, UnderlineSpan, ...
Read more >
Cannot Display View On Top Of Button Inside Merge
I have a Button which I want to display another View on top of. In my xml, the Button is defined as: <Button...
Read more >
FAQ — Customer Information
If you don't see your question, please don't hesitate to get in touch. ... My style spans what is natural, candid, fun, emotion-filled,...
Read more >
Alternate Token/StyleSpan Design - Actipro Software
8) We may even be able to add an option for whether to persist StyleSpans for lines. If we are not persisting, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found