-
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
Highlight a particular line via CSS within a multi-line paragraph #611
Comments
Currently, no, there is not a way to do that. However, we could add another pseudo class that would activate when the caret is on that specific line. |
Could you point me in the general direction of how I could add that myself? I'm happy to add these features myself and then make them available as PRs if needed. I just need the best place to start looking. |
It'll need to be added in |
Thanks. That sets me in the right direction. I'm thinking here that perhaps it would be better to look at this in a broader scope. That is, to allow for any number of "selections" or highlights to be made in an area. For example, to allow for multiple search results to be highlighted or perhaps keywords highlighted. So if I create a For example if I have the paragraphs:
and then want to add a highlight between 8 and 32 (the start of the first "the" and the start of the second "the"), I will have to add two paths, one for each |
That sounds like #222 |
It sounds very similar. I'm going to have a go at implementing the feature. Any suggestions on the best way to manage moving the Path selections around the ParagraphText nodes? I was thinking of just listening for viewport and text changes and adding/removing the selections as appropriate. |
Mm.... this gets a bit complicated. Styling the individual lines of a multi-line paragraph has no relation whatsoever to the text (or segment)'s style. After realizing this, one might say it should go into the paragraph style. However, I'm not sure this is the best route either. There are a number of problems that have to be resolved:
|
I think most of the work has been done in the SelectionImpl class. With another class, say "Highlight" that would encapsulate a Selection instance and a style (StyleableObjectProperty). The highlight, as I'm talking about would not be for a line, but for an index range, a from/to combination. The caret line highlighting would be a special case where the from/to would be recalculated when the viewport changes size. As part of #613 I'm looking into querying the virtual flow to determine what line(s) are currently visible in the viewport. Lines 1285-1291 of GenericStyledArea show a potential binding mechanism. I'll look into using something similar for the selections although I'll need to detect when the selection is no longer valid for the paragraph and remove it to prevent the potential memory leak. Once I have a working prototype I'll let you know. |
Yes it looks almost the same to what I'm looking for. Sorry for the delay, had a busy few days. I'll bear those issues in mind when implementing my prototype. |
So the style and psuedo-class:
.paragraph-box:has-caret
{
}
allows you to style a paragraph which works well when a paragraph is also just the entire line but in the case where you have a paragraph spanning/wrapping onto multiple lines within the view it doesn't really give you what you want. It will style the entire paragraph rather than a line within it.
Thus if I have a single paragraph:
If I want to highlight the line starting "We imagine..." what is the best way to do that? I should add here that the caret will be somewhere along that line in the view.
That is, I want to highlight the current line that the user is typing on (they will be typing continuous prose). As the caret moves down the highlighted line should shift.
Do I need to add an external overlay (a highlight region as part of a StackPane) or is there a way within GenericStyledArea to do it?
The text was updated successfully, but these errors were encountered: