pyscripter / SynEdit

SynEdit is a syntax highlighting edit control, not based on the Windows common controls.
26 stars 11 forks source link

Built-in matching braces highlighting #31

Closed pyscripter closed 1 year ago

pyscripter commented 1 year ago
Originally posted by **pyscripter** March 18, 2022 I propose to add matching-braces highlighting functionality into SynEdit, implemented with indicators: - TSynCustomHighlighter gets two attributes MatchingBraceAttri, UnbalancedBraceAttri and a Braces property ('()[]{}<>') - TSynEditorOption gets a new member eoHighlightMatchingBraces - TSynEdit.SetCaretXYEx and TSynEdit.LinesChanged clear existing matching brace indicators and check for new ones if a highlighter is attached and eoHighlightMatchingBraces is set. Given, that we use highlighter attributes, this would allow to set Foreground, Background color and font style for matching braces, but not say painting a rectangle around the matching braces.
pyscripter commented 1 year ago

See https://github.com/pyscripter/SynEdit/discussions/34 for the actual implementation.

@MShark67 Could you please have a look and test this new feature?

MShark67 commented 1 year ago

Initial testing seems very good! I couldn't break it in any of my tests. Performance seems good and I only saw slowdowns under extreme testing that would probably never happen in the real world. Nicely done!

pyscripter commented 1 year ago

@MShark67 Thanks. When you have some time could you please have a look at the related #35.

For highlighters that need a different default for Brackets than, '()[]{}' (e.g. XML) we need to set:

DefaultBrackets := '??';
Brackets := DefaultBrackets;

in their constructor. These brackets are also used in GetMatchingBracket.