danipen / TextMateSharp

A port of tm4e to bring TextMate grammars to dotnet ecosystem
MIT License
101 stars 19 forks source link

Custom Grammars - Where to Start #20

Closed jamsoft closed 2 years ago

jamsoft commented 2 years ago

I'm using AvaloniaEdit and am using it as a replacement for a WPF RichTextBox I was using in a custom control.

Look at the AE docs it says I need to implement IRegistryOptions but I can't find any examples of what any of the requirements are for doing so. This is all pretty complex stuff and I can't find anything to give me a nudge in the right direction.

I found a message saying to look at the implementation for AvaloniaEdit but the link is now a 404 and looking over all the branches it seems to have vanished.

My requirements are really simple.

I just have a handful of key words to be green and a handful of keywords to be Red but I just cannot figure out what to do with the interface. It all seems geared up for a much more complex use case and I'm left struggling a bit to be honest.

Are there any docs I'm missing or examples?

danipen commented 2 years ago

I don't think TextmateSharp is the piece you should use for that. I'd use AvaloniaEdit's transformers for that.

Basically you need to write a line transformer that just change the chunk style when you find a match in your line.

You can find a custom transformer here: https://github.com/AvaloniaUI/AvaloniaEdit/blob/master/src/AvaloniaEdit.TextMate/GenericLineTransformer.cs