Skip to content

Added setVisibleOnlyStyler method #1277

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Jugen
Copy link
Collaborator

@Jugen Jugen commented May 22, 2025

Addresses #1273 where styles are not always being applied.

To apply styling to particular portion of text we need to have a position of where that text is. The trouble is that the changes/modifications supplied by getVisibleParagraph don't provide a document paragraph index so it has to be queried with firstVisibleParToAllParIndex which at that point in time returns stale values as the scene graph hasn't been updated yet.

Here I've added a new method setVisibleOnlyStyler to GenericStyledArea that can be used to style paragraphs just before being displayed.

and use in JavaKeywordsDemo
@Jugen Jugen changed the title Added getVisibleParagraphIndexes method Added setVisibleOnlyStyler method May 26, 2025
@@ -1548,6 +1548,20 @@ public final PS getParagraphStyleForInsertionAt(int pos) {
}
}

private UnaryOperator<Paragraph<PS, SEG, S>> visibleOnlyStyler;
/**
* This styler will only be applied to Paragraphs, just before being displayed.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosmetic: I think the world "visible" is missing: "This style will only be applied to visible Paragraphs"

@@ -1548,6 +1548,20 @@ public final PS getParagraphStyleForInsertionAt(int pos) {
}
}

private UnaryOperator<Paragraph<PS, SEG, S>> visibleOnlyStyler;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I do have an issue with this one. For some cases that might be good enough (those where the style fully depend only on the content of the line).
In my scenario, I have a group comment, meaning that the style of a line depends on its position.
Would it be possible to provide the paragraph and its position?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants