-
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
IndexRange of style span #50
Comments
Hi Maher, it's best if you post the code. I guess what is happening here is that when you get the style spans for "or", you get two style spans, each spanning 1 character. When you the call mapStyles, this switches the styles in the spans, but there are still two spans of length 1. The text area should probably merge them together, if they have the same style (in terms of |
Yes that is my guess too. |
Please, try the new jar. |
Hi Tomas, I tried it. It seems to works on the first and second attempts, but then starts missing characters on the both ends (before and after). I'll do more testing to try to narrow down the issue. |
I did further testing, I think there is something to do with the line number somewhere |
Can you post a self-contained (runnable) code that demonstrates the problem? On Wed, Apr 30, 2014 at 12:06 AM, melkhaldi [email protected]:
|
A runnable example will take me a long time to factor out. For now, these are the code bits I am using in the following steps: -Type text: This is the code I am using to: **Code to apply style to Selection (style coming as a cleaned up CSS string). Something like:
**Code to apply style to a span (triggered by hitting a button).
|
Can you narrow down which method is problematic? Is it |
I believe the issue is with the getStyleRangeAtPosition. I also verified this by listening to caret change and printing text for the The setStyle works fine. I use it everywhere else and things work as On Tue, Apr 29, 2014 at 5:08 PM, TomasMikula [email protected]:
|
on another note, I just printed the style at caret using: END: Style At position is: -fx-font-family: Arial;-fx-font-size: something in the setStyle() probably cases the range detection to break. On Tue, Apr 29, 2014 at 5:25 PM, Maher Elkhaldi [email protected]:
|
In the code you posted before, can you add if(pos < start || pos > end) {
throw new AssertionError("style range [" + start + "," + end + "] does not contain caret position " + pos);
} after int pos = activePort.richTextArea.caretPositionProperty().get();
int start = activePort.richTextArea.getStyleRangeAtPosition(pos).getStart();
int end = activePort.richTextArea.getStyleRangeAtPosition(pos).getEnd(); and see if the exception gets thrown? |
no exception is thrown. On Tue, Apr 29, 2014 at 6:51 PM, TomasMikula [email protected]:
|
so it must be in the setStyle(), right? On Tue, Apr 29, 2014 at 6:59 PM, Maher Elkhaldi [email protected]:
|
So it seems. |
Is the set style method designed to concatenate styling information to the What I ended up doing for preparing for a file format is a method that gets
|
It replaces the style. You wouldn't have to write such a method if you used |
Yes I agree. I didn't really get the difference when I first started
|
Hi Tomas, I managed to get it to work this way: This is the method to get an index range:
this is the method that fetches the values from the style:
It seems to work fine so far. |
Well, that is a lot of code that you wouldn't have to write if you used custom style representation instead of raw CSS string. |
true :D Were you able to confirm that the setStyle method (when working on raw CSS) generates extra styling information like the one I posted above? |
There's no way |
oh ok. so I can probably perform the style cleaning after I do the map On Wed, Apr 30, 2014 at 8:59 AM, TomasMikula [email protected]:
|
Yes, or rather in mapStyles. Instead of
do
|
Hi Tomas, I have been testing this. it seems there is an issue.
In "word", if you make wo red, and detect the span index range, it will be correct,
"wo" is a range, and "rd" is a range.
but if you apply a color again to "or", so coloring should be like "w" "or" "d", and you click in "or", the span will only detect the O (from previously applied style.
Can you reproduce this?
I am using the richTextArea.getStyleRangeAtPosition(caretpos);
The text was updated successfully, but these errors were encountered: