Skip to content
プロジェクト

概要

Avalonia ベースのテキストエディター(AvalonEdit の移植版)

開発ツール

この数値の測り方

計測したスター増加

24時間
+1
7日間
+1
15日間
+2
1か月
+2

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

downloads Current stable version

AvaloniaEdit

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

AvaloniaEdit supports features like:

  • Syntax highlighting using TextMate 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 an empty Avalonia application.
  • Add a the nuget reference to the latest version: <PackageReference Include="Avalonia.AvaloniaEdit" Version="x.y.z.t" />
  • Include the needed styles into your <Application.Styles> in your App.xaml:
    <Application xmlns="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!) -->
        <StyleInclude Source="avares://AvaloniaEdit/Themes/Fluent/AvaloniaEdit.xaml" />
    
      </Application.Styles>
    </Application>
    
  • Finally, add the AvaloniaEdit editor into your window:
    <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>
    

You can see the Demo 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 by TextMateSharp, 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 = 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

Building

Clone with submodules (git clone --recursive, or git submodule update --init after cloning), then use dotnet build / dotnet test as usual.

Packaging is driven by a NUKE build in build/:

# Run tests, build and pack every library into artifacts/packages, then install
# them into the local NuGet cache as 9999.0.0-localbuild for testing in other apps
dotnet run --project build/_build.csproj

# Only create the packages (and their SBOMs)
dotnet run --project build/_build.csproj -- --target CreateNugetPackages

Translations

Czech, French, German, Italian, Japanese, Korean, Polish, Portuguese (Brazil), Russian, Spanish, Turkish and Chinese (Traditional) are adapted from the Visual Studio Code localization (MIT, Microsoft). Swedish by Svante Seleborg.

関連プロジェクトを探す

読み込み中…