icsharpcode / AvalonEdit

The WPF-based text editor component used in SharpDevelop
http://avalonedit.net/
MIT License
1.85k stars 469 forks source link

Rule Regex doesn't work as expected #392

Closed MathiasLui closed 1 year ago

MathiasLui commented 1 year ago

Hey, I've got a syntax highlighting rule that should match the first word of each line like this: <Rule color="CmdOrVar"> ^[+\-_a-zA-Z]([\w]*)?(\s|$) </Rule> and it works when trying it on regexr: image But in the Editor it looks like this and it feels like it's deciding for each word instead of each line: image

MathiasLui commented 1 year ago

I have tried so long for different solutions for this as well as some other things and it feels impossible to do anything more with regex than just highlighting certain keywords, strings or comments...

Is there maybe a way to write my own logic for highlighting text, based on code instead of regex?

jimfoye commented 1 year ago

You can derive a class from DocumentColorizingTransformer.

MathiasLui commented 1 year ago

Thanks I'll try that!

MathiasLui commented 1 year ago

Thanks, I managed to make that work, uglily, but it works