bobbylight / RSyntaxTextArea

A syntax highlighting, code folding text editor for Java Swing applications.
BSD 3-Clause "New" or "Revised" License
1.12k stars 259 forks source link

Allow customization of ErrorStrip painting #535

Closed CGJennings closed 7 months ago

CGJennings commented 9 months ago

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:

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.)