Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avalonia-based text editor (port of AvalonEdit)

License

NotificationsYou must be signed in to change notification settings

AvaloniaUI/AvaloniaEdit

Repository files navigation

downloadsCurrent stable version

AvaloniaEdit

This project is a port ofAvalonEdit, a WPF-based text editor forAvalonia.

AvaloniaEdit supports features like:

  • Syntax highlighting usingTextMate grammars and themes.
  • Code folding.
  • Code completion.
  • Fully customizable and extensible.
  • Line numeration.
  • Display whitespaces EOLs and tabs.
  • Line virtualization.
  • Multi-caret edition.
  • Intra-column adornments.
  • Word wrapping.
  • Scrolling below document.
  • Hyperlinks.

and many,many more!

AvaloniaEdit currently consists of 2 packages

Getting started

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

  • Create anempty Avalonia application.
  • Add a thenuget reference to the latest version:<PackageReference Include="Avalonia.AvaloniaEdit" Version="x.y.z.t" />
  • Include theneeded styles into your<Application.Styles> in yourApp.xaml:
    <Applicationxmlns="https://github.com/avaloniaui"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"x:Class="MyAvaloniaApplication.App"RequestedThemeVariant="Default">  <Application.Styles>    <FluentTheme /><!-- AvaloniaEdit styles (required!)-->    <StyleIncludeSource="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />  </Application.Styles></Application>
    • If you're using0.10.x.y based versions, include<StyleInclude Source="avares://AvaloniaEdit/AvaloniaEdit.xaml" />
    • If you're11.x.y based versions, include<StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
  • Finally, add the AvaloniaEdit editor into your window:
    <Windowxmlns="https://github.com/avaloniaui"        ...xmlns:AvaloniaEdit="clr-namespace:AvaloniaEdit;assembly=AvaloniaEdit"        ...>  ...  <AvaloniaEdit:TextEditorText="Hello AvaloniaEdit!"ShowLineNumbers="True"FontFamily="Cascadia Code,Consolas,Menlo,Monospace"/>  ...</Window>

You can see theDemo Application as a reference.

How to set up TextMate theme and syntax highlighting for my project?

First of all, if you want to use grammars supported byTextMateSharp, should install the following packages:

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=newRegistryOptions(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


[8]ページ先頭

©2009-2025 Movatter.jp