errael commented on pull request #2482: URL: https://github.com/apache/netbeans/pull/2482#issuecomment-717312901
**Recapitulation** The problem is that in `BaseCaret` the `caretBounds`, which becomes the clip region, is essentially set directly from `modelToView` without regard to the caret's drawing algorithms. This is usually OK since caret is typically drawn over a "normal" character and there's typically no need to draw outside the character bounds. However for the TAB, and probably for other invisible characters, modelToView provides unreasonable values (width 1). I believe the caret drawing algorithm should have input into the required bounding box; relying on historical information from paintCustomCaret seems wrong. One possibility is to have a method, for example `int getCaretMinWidth(...)` or maybe `Dimension getCaretSize(...)` or ... The idea of using a property gives considerable flexibility for experimenting with different solutions without having a hard signature-API and breaking client code at compile or runtime. The worst that happens is reverting back to poor choice of clip region. Using an `IntUnaryOperator` seems simplest for now (considering the problem has existed for 10 years with BaseCaret and 5 years for EditorCaret). This could be changed in the future to require a `Funtion` which accepts an API defined input object parameter and returns a Dimension, or a Rectangle, or an Integer. If such a change were made, BaseCaret could continue to support the simple IntUnaryOperator or not (this is marked devel, it can change). All without an API-signature change. If in the fullness of time there's an accepted solution, a method could be added. Other solutions could involve punting and giving "huge" clip regions. Having a way to get a value from `paintCustomCaret` could be designed, but it seems wrong and it's hard to see how that would work without major redesign; using an old value doesn't make sense particularly if variable fonts are used. There are undoubtedly other solutions. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected] For further information about the NetBeans mailing lists, visit: https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
