AvaloniaEdit
11.1.0
Este projeto é um porto de Avalonedit, um editor de texto baseado em WPF da Avalonia.
Avaloniaedit suporta recursos como:
E muitos, muitos mais!
Avaloniaedit atualmente consiste em 2 pacotes
<PackageReference Include="Avalonia.AvaloniaEdit" Version="xyzt" /><Application.Styles> em seu App.xaml :0.10.xy , inclua <StyleInclude Source="avares://AvaloniaEdit/AvaloniaEdit.xaml" />11.xy versões, inclua <StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />< Window xmlns = " https://github.com/avaloniaui "
...
xmlns : AvaloniaEdit = " clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit "
...>
...
< AvaloniaEdit : TextEditor Text = " Hello AvaloniaEdit! "
ShowLineNumbers = " True "
FontFamily = " Cascadia Code,Consolas,Menlo,Monospace " />
...
</ Window >Você pode ver o aplicativo de demonstração como uma referência.
Primeiro de tudo, se você deseja usar gramáticas suportadas pelo TextMatesharp, deve instalar os seguintes pacotes:
Como alternativa, se você deseja suportar suas próprias gramáticas, basta instalar o pacote Avaloniaedit.textmate e implementar a interface do IregistryOptions, atualmente é a maneira mais fácil, caso você queira usar o AvaloniaEdit com o conjunto de gramáticas diferentes do 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 ) ) ; 