AvaloniaUI / AvaloniaEdit

Avalonia-based text editor (port of AvalonEdit)
MIT License
746 stars 148 forks source link
avalonia code-editor editor netstandard text-editor

downloads Current stable version

AvaloniaEdit

This project is a port of AvalonEdit, a WPF-based text editor for Avalonia.

AvaloniaEdit supports features like:

AvaloniaEdit currently consists of 2 packages

Getting started

How to set up a new project that displays an AvaloniaEdit editor?

Alternatively, if you want to support your own grammars, you just need to install the AvaloniaEdit.TextMate package, and implement IRegistryOptions interface, that's currently the easiest way in case you want to use AvaloniaEdit with the set of grammars different from in-bundled TextMateSharp.Grammars.

//First of all you need to have a reference for your TextEditor for it to be used inside AvaloniaEdit.TextMate project.
var _textEditor = this.FindControl<TextEditor>("Editor");

//Here we initialize RegistryOptions with the theme we want to use.
var  _registryOptions = new RegistryOptions(ThemeName.DarkPlus);

//Initial setup of TextMate.
var _textMateInstallation = _textEditor.InstallTextMate(_registryOptions);

//Here we are getting the language by the extension and right after that we are initializing grammar with this language.
//And that's all 😀, you are ready to use AvaloniaEdit with syntax highlighting!
_textMateInstallation.SetGrammar(_registryOptions.GetScopeByLanguageId(_registryOptions.GetLanguageByExtension(".cs").Id));

avaloniaedit-demo