Closed Rekkonnect closed 4 months ago
AvaloniaEdit is a powerful code editor written in Avalonia with quite advances features. It could help with syntax highlight, multi caret, show tabs/white spaces, search and replace... etc. I encourage you to take a look.
Thanks for the suggestion. My only concern is the syntax highlighting. AvaloniaEdit doesn't seem to provide a way for custom highlighting, or does it? It would however be very nice to avoid having to implement all these features by hand.
As you have all the tokens, probably your best choice is implementing a new custom syntax highlight. You can see an example here: https://github.com/AvaloniaUI/AvaloniaEdit/blob/88625c4491af8ca6fa9127872ae1f1099fd06392/src/AvaloniaEdit.TextMate/GenericLineTransformer.cs#L32
Anyway, coloring lines (background, foreground, text style) is an extensible mechanism, so if you don't want to rewrite the whole syntax highlight you can probably write a new DocumentColorizedTransformer to do your stuff.
Thanks for the guidance, I'll have a look around
The code editor can receive a syntax highlighting buff. However, we won't speculatively update the highlighting live until another pass.
While typing, the characters that were already there will preserve their original highlighting until the analysis is performed. The inserted characters will not be highlighted until the pass is done. Removing characters will adjust the highlighting of existing characters correspondingly.
The syntax highlighting can be split into two stages, one syntactic and one semantic. The semantic pass will show more information about identifiers that are not already classified. Declared symbols can be semantically analyzed in the syntactic pass since we already know their classification from their syntax parents.
During both passes, the code editor lines will be invalidated regionally, and the updating will happen by using channels, to reduce the overhead of the semantic analysis.