EonaCat.Editor
0.0.2
Prefix Reserved
dotnet add package EonaCat.Editor --version 0.0.2
NuGet\Install-Package EonaCat.Editor -Version 0.0.2
<PackageReference Include="EonaCat.Editor" Version="0.0.2" />
<PackageVersion Include="EonaCat.Editor" Version="0.0.2" />
<PackageReference Include="EonaCat.Editor" />
paket add EonaCat.Editor --version 0.0.2
#r "nuget: EonaCat.Editor, 0.0.2"
#:package EonaCat.Editor@0.0.2
#addin nuget:?package=EonaCat.Editor&version=0.0.2
#tool nuget:?package=EonaCat.Editor&version=0.0.2
EonaCat.Editor
A modern, lightweight, and highly extensible WPF text editor control for .NET applications.
EonaCat.Editor provides a fast editing experience with syntax highlighting, code completion, snippets, search, undo/redo, and a powerful document model, making it suitable for IDEs, scripting tools, configuration editors, and code editing applications.
Features
- đ Fast WPF rendering engine
- đ¨ Syntax highlighting
- đĄ IntelliSense-style code completion
- đ Snippet support
- đ Built-in search panel
- âŠī¸ Unlimited Undo / Redo
- đ Line numbers
- âī¸ Clipboard operations
- đ¯ Caret API
- đ Selection API
- đ TextDocument model
- đ Scroll position API
- đ¤ Word wrapping
- đ Fully customizable through WPF styling
- ⥠Optimized for large documents
Installation
Install from NuGet.
Package Manager
Install-Package EonaCat.Editor
.NET CLI
dotnet add package EonaCat.Editor
Quick Start
Add the namespace
xmlns:editor="clr-namespace:EonaCat.Editor.Core;assembly=EonaCat.Editor"
Add the editor
<Grid>
<editor:TextEditor
x:Name="Editor"
FontFamily="Consolas"
FontSize="14"
ShowLineNumbers="True"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"/>
</Grid>
Loading Text
Editor.Text = File.ReadAllText("Program.cs");
Saving Text
File.WriteAllText("Program.cs", Editor.Text);
Using a TextDocument
The editor stores all text inside a TextDocument.
Create a document:
var document = new TextDocument();
document.Text = "Hello World";
Editor.Document = document;
Read the current document:
string text = Editor.Document.Text;
Basic Properties
Text
Editor.Text = "Hello World";
string current = Editor.Text;
Read Only
Editor.IsReadOnly = true;
Word Wrap
Editor.WordWrap = true;
Show Line Numbers
Editor.ShowLineNumbers = true;
Font
<editor:TextEditor
FontFamily="Consolas"
FontSize="14"/>
Line Number Color
Editor.LineNumbersForeground = Brushes.Gray;
Undo / Redo
if (Editor.CanUndo)
{
Editor.Undo();
}
if (Editor.CanRedo)
{
Editor.Redo();
}
Caret
Move the caret.
Editor.CaretOffset = 0;
Read the current position.
int position = Editor.CaretOffset;
Selection
Read the selected text.
string text = Editor.SelectedText;
Select text.
Editor.SelectionStart = 50;
Editor.SelectionLength = 20;
Scrolling
double vertical = Editor.VerticalOffset;
double horizontal = Editor.HorizontalOffset;
Viewport size.
double width = Editor.ViewportWidth;
double height = Editor.ViewportHeight;
Syntax Highlighting
Assign a highlighting definition.
Editor.SyntaxHighlighting = myHighlightingDefinition;
You can create custom highlighting definitions for your own languages.
Search
The built-in search panel supports:
- Find
- Find Next
- Find Previous
- Match Case
- Whole Word
- Regular Expressions
- Highlight All
Example:
SearchPanel.Install(Editor.TextArea);
Code Completion
Show an IntelliSense completion window.
var completionWindow = new CompletionWindow(Editor.TextArea);
completionWindow.CompletionList.CompletionData.Add(
new MyCompletionData("Console"));
completionWindow.Show();
The completion system supports:
- Keyboard navigation
- Icons
- Descriptions
- Automatic insertion
- Custom completion providers
Snippets
Insert reusable code templates.
Example features:
- Editable placeholders
- Caret positioning
- Bound fields
- Replaceable regions
- Selection support
Snippets can be created and inserted programmatically using the included snippet APIs.
Mouse Hover
Useful for tooltips and quick info.
Editor.MouseHover += Editor_MouseHover;
Editor.MouseHoverStopped += Editor_MouseHoverStopped;
Document Information
Determine whether the document has changed.
bool modified = Editor.IsModified;
Retrieve the number of lines.
int lines = Editor.LineCount;
Current encoding.
Encoding encoding = Editor.Encoding;
Styling
Since the editor is a normal WPF control, it fully supports:
- Styles
- Control Templates
- Resource Dictionaries
- Dynamic Resources
- Themes
Example:
<Style TargetType="editor:TextEditor">
<Setter Property="Background"
Value="#1E1E1E"/>
<Setter Property="Foreground"
Value="White"/>
</Style>
Complete Example
XAML
<Window
x:Class="Sample.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:editor="clr-namespace:EonaCat.Editor.Core;assembly=EonaCat.Editor">
<Grid>
<editor:TextEditor
x:Name="Editor"
FontFamily="Consolas"
FontSize="14"
ShowLineNumbers="True"
WordWrap="False"
VerticalScrollBarVisibility="Auto"
HorizontalScrollBarVisibility="Auto"/>
</Grid>
</Window>
Code Behind
using System.Windows;
namespace Sample
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Editor.Text =
@"using System;
Console.WriteLine(""Hello World!"");";
}
}
}
Included Components
The package includes:
- TextEditor
- TextDocument
- Search Panel
- Completion Window
- Completion List
- Insight Window
- Snippet Engine
- Syntax Highlighting Engine
- Rendering Engine
- Undo / Redo Manager
Typical Use Cases
EonaCat.Editor is ideal for:
- Source code editors
- IDEs
- Script editors
- JSON editors
- XML editors
- SQL editors
- Markdown editors
- Configuration editors
- Log viewers
- Custom programming languages
Supported Frameworks
- .NET Framework 4.8
- .NET 6 Windows
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0-windows7.0 is compatible. net7.0-windows was computed. net8.0-windows was computed. net9.0-windows was computed. net10.0-windows was computed. |
| .NET Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- No dependencies.
-
net6.0-windows7.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on EonaCat.Editor:
| Package | Downloads |
|---|---|
|
EonaCat.MarkdownEditor
A feature-rich Markdown-to-FlowDocument rendering engine and WPF viewer control for .NET. |
GitHub repositories
This package is not used by any popular GitHub repositories.