AvaloniaTerminal 1.0.0-alpha.11

This is a prerelease version of AvaloniaTerminal.
dotnet add package AvaloniaTerminal --version 1.0.0-alpha.11
                    
NuGet\Install-Package AvaloniaTerminal -Version 1.0.0-alpha.11
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AvaloniaTerminal" Version="1.0.0-alpha.11" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AvaloniaTerminal" Version="1.0.0-alpha.11" />
                    
Directory.Packages.props
<PackageReference Include="AvaloniaTerminal" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AvaloniaTerminal --version 1.0.0-alpha.11
                    
#r "nuget: AvaloniaTerminal, 1.0.0-alpha.11"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AvaloniaTerminal@1.0.0-alpha.11
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AvaloniaTerminal&version=1.0.0-alpha.11&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=AvaloniaTerminal&version=1.0.0-alpha.11&prerelease
                    
Install as a Cake Tool

AvaloniaTerminal

Nuget (with prereleases) Nuget (with prereleases)

Avalonia terminal control built on top of XTerm.NET.

screenshot

Features

  • Terminal rendering backed by XTerm.NET
  • Scrollback with mouse wheel, scrollbar, PageUp, and PageDown
  • Caret rendering with theme-aware default styling
  • Text selection with drag, double-click word selection, triple-click row selection, and drag auto-scroll
  • Bindable selection state via SelectedText and HasSelection
  • Search helpers for finding and navigating matches in the terminal buffer
  • Mouse reporting mode support for xterm-compatible terminal apps
  • Host-friendly context menu and clipboard hooks
  • Configurable right-click behavior via RightClickAction
  • Model-driven API for feeding terminal output and sending user input
  • Sample desktop app with Shell, Scroll, and Selection tabs
  • Windows sample shell backed by ConPTY, with redirected-shell fallback when ConPTY is unavailable
  • Sample shell disables resize reflow to avoid TUI resize corruption in apps such as mc

Install

dotnet add package AvaloniaTerminal

Basic Usage

Add the control in XAML:

<Window
    xmlns="https://github.com/avaloniaui"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:terminal="using:AvaloniaTerminal">
    <terminal:TerminalControl Name="TerminalView" />
</Window>

Create and assign a TerminalControlModel in code-behind or a view model:

using Avalonia.Controls;

namespace MyApp;

public partial class MainWindow : Window
{
    private readonly TerminalControlModel _terminal = new();

    public MainWindow()
    {
        InitializeComponent();
        TerminalView.Model = _terminal;
    }
}

You can also pass TerminalOptions when you need non-default terminal behavior:

var model = new TerminalControlModel(new TerminalOptions
{
    ReflowOnResize = false,
});

Feed terminal output:

_terminal.Feed("Hello from AvaloniaTerminal\r\n");

Receive user input:

_terminal.UserInput += bytes =>
{
    // Send bytes to a pty, process stdin, socket, ssh session, etc.
};

Common Integration Pattern

The usual flow is:

  1. Create a TerminalControlModel
  2. Bind or assign it to TerminalControl.Model
  3. Forward terminal output into model.Feed(...)
  4. Forward model.UserInput to your process or remote shell

Example with a local process or remote session:

var model = new TerminalControlModel();

model.UserInput += bytes =>
{
    process.StandardInput.BaseStream.Write(bytes, 0, bytes.Length);
    process.StandardInput.BaseStream.Flush();
};

_ = Task.Run(async () =>
{
    var buffer = new byte[4096];

    while (true)
    {
        var read = await process.StandardOutput.BaseStream.ReadAsync(buffer);
        if (read == 0)
        {
            break;
        }

        model.Feed(buffer, read);
    }
});

Core APIs

TerminalControlModel:

  • Feed(string) / Feed(byte[], int) for terminal output
  • Send(string) / Send(byte[]) for programmatic input
  • ScrollLines(int), PageUp(), PageDown(), ScrollToYDisp(int)
  • Search(string), SelectNextSearchResult(), SelectPreviousSearchResult()
  • SelectAll(), ClearSelection()
  • SelectedText, HasSelection
  • ScrollOffset, MaxScrollback
  • CaretColumn, CaretRow, IsCaretVisible
  • IsMouseModeActive
  • SizeChanged
  • Terminal, SelectionService, SearchService

TerminalControl:

  • Model
  • SelectedText, HasSelection
  • RightClickAction
  • IsMouseModeActive
  • FontFamily, FontSize, CaretBrush, SelectionBrush
  • SelectAll()
  • CopySelection()
  • CopySelectionAsync()
  • Paste(string)
  • PasteFromClipboardAsync()
  • Search(string)
  • SelectNextSearchResult()
  • SelectPreviousSearchResult()
  • ContextRequested

TerminalOptions used by TerminalControlModel:

  • Scrollback
  • ConvertEol
  • TabStopWidth
  • TermName
  • ReflowOnResize

Selection And Context Menus

Clients often want to enable a context menu item only when text is selected. TerminalControl exposes that directly:

if (TerminalView.HasSelection)
{
    var text = TerminalView.CopySelection();
}

You can also bind against SelectedText and HasSelection from the control or the model, or handle ContextRequested for a custom menu.

Selection behavior:

  • drag selects text
  • double-click selects a word or expression
  • triple-click selects a full row
  • dragging above or below the viewport auto-scrolls and keeps extending the selection

Right-click behavior is configurable:

  • ContextMenu: raise ContextRequested
  • CopyOrPaste: copy when selection exists, otherwise paste from the clipboard
  • None: ignore right-click

Example:

<terminal:TerminalControl RightClickAction="CopyOrPaste" />

Programmatic clipboard helpers:

await TerminalView.CopySelectionAsync();
await TerminalView.PasteFromClipboardAsync();

ContextRequested carries:

  • pointer position relative to the control
  • current SelectedText
  • current HasSelection

Search is buffer-based

var count = TerminalView.Search("error");

if (count > 0)
{
    TerminalView.SelectNextSearchResult();
}

Useful model properties:

  • SearchResultCount
  • CurrentSearchResultIndex
  • LastSearchText

Mouse Reporting

When the terminal application enables mouse reporting, TerminalControl forwards pointer press, release, and motion events to XTerm.NET instead of using them for text selection. This allows interactive terminal applications to receive mouse input.

This is controlled by the terminal app, not by the Avalonia host. If an app does not switch the terminal into xterm mouse mode, the control will keep using the pointer for normal text selection.

Styling

The library includes terminal color resources in:

The desktop sample includes those resources automatically. If you host the control yourself, include the style resource in your application when needed:

<Application.Styles>
    <StyleInclude Source="avares://AvaloniaTerminal/Styles/Colors.axaml" />
</Application.Styles>

Useful styling hooks on TerminalControl:

  • FontFamily
  • FontSize
  • CaretBrush
  • SelectionBrush

Samples

The repo includes a shared samples project and a desktop sample host.

Current sample tabs:

  • Shell: starts a platform-appropriate shell
    • Windows: prefers ConPTY-backed pwsh.exe, with redirected fallback
    • macOS/Linux: uses the existing redirected-shell sample backend
    • uses RightClickAction="CopyOrPaste"
    • constructs the model with ReflowOnResize = false to keep full-screen TUIs stable during window resize
  • Scroll: preloaded scrollback sample
  • Selection: demonstrates selection and bindable selected text

Desktop sample host:

Shared sample controls:

Running The Sample App

dotnet run --project src/AvaloniaTerminal.Desktop

Sample shell notes

  • On Windows, the sample uses ConPTY when available.
  • Full-screen TUIs such as mc render correctly with the current ambiguous-width fix and with resize reflow disabled in the sample shell.
  • Mouse interaction in TUIs still depends on the application enabling xterm mouse reporting. Remote Linux apps often do this; some local Windows console apps may not.

Testing

The repo has headless tests covering terminal behavior without needing a visible desktop session.

dotnet test --project tests/AvaloniaTerminal.Tests/AvaloniaTerminal.Tests.csproj -f net10.0
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AvaloniaTerminal:

Package Downloads
AvaloniaTerminal.Samples

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on AvaloniaTerminal:

Repository Stars
IvanJosipovic/KubeUI
Kubernetes User Interface
Version Downloads Last Updated
1.0.0-alpha.11 50 3/27/2026
1.0.0-alpha.10 44 3/26/2026
1.0.0-alpha.9 30 3/26/2026
1.0.0-alpha.8 98 3/22/2026
1.0.0-alpha.7 4,324 11/1/2025
1.0.0-alpha.6 106 10/31/2025
1.0.0-alpha.5 99 10/31/2025
1.0.0-alpha.4 181 10/31/2025
1.0.0-alpha.3 8,549 1/28/2025
1.0.0-alpha.2 142 1/24/2025
1.0.0-alpha.1 133 1/24/2025