Skip to content
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

Allow customization of ErrorStrip painting #535

Merged

Conversation

CGJennings
Copy link
Contributor

ErrorStrip does not expose a way to change how markers are painted (for example, to draw them with a "flat" UI style). To change the painting style you must make a private copy of the class and then keep it in synch with upstream changes. This PR addresses this with the following changes:

  • caret painting delegates to a new protected method paintCaretMarker(g, w, h)
  • marker painting delegates to a new protected method paintParserMarkerNotice(g, notice, w, h)
  • a new property, caretMarkerOnTop, allows control over whether the caret marker is drawn under other markers (as it currently is) or over them

The painting delegates expose a small rectangle (the width of the component and the height of a parser notice marker) for the subclass to paint as desired. In the case of the caret delegate, the rectangle is centered around the y-position for the caret. The base class paints the markers in the same style as the original implementation.

A future change might allow the subclass to choose which notice(s) to paint, but that is not addressed here. It uses the existing method in Marker to choose a notice based on priority, slightly modified (and suitably renamed) to return the notice rather than its colour. (As an example of how multiple notices might be used, in VS Code there is a similar strip but different kinds of markers (errors, search matches, diffs) are drawn in different columns.)

@bobbylight bobbylight self-requested a review April 12, 2024 22:55
Copy link
Owner

@bobbylight bobbylight left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the PR

@bobbylight bobbylight merged commit 9347d1a into bobbylight:master Apr 12, 2024
@bobbylight bobbylight added this to the 3.4.1 milestone Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants