Terminal.Pty 0.2.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Terminal.Pty --version 0.2.0
                    
NuGet\Install-Package Terminal.Pty -Version 0.2.0
                    
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="Terminal.Pty" Version="0.2.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Terminal.Pty" Version="0.2.0" />
                    
Directory.Packages.props
<PackageReference Include="Terminal.Pty" />
                    
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 Terminal.Pty --version 0.2.0
                    
#r "nuget: Terminal.Pty, 0.2.0"
                    
#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 Terminal.Pty@0.2.0
                    
#: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=Terminal.Pty&version=0.2.0
                    
Install as a Cake Addin
#tool nuget:?package=Terminal.Pty&version=0.2.0
                    
Install as a Cake Tool

Terminal.Avalonia

A lightweight, fast terminal-emulator control for Avalonia (.NET 10), built from scratch — not a wrapper around an existing emulator. Designed to host any terminal program (PowerShell, bash, …) and full-screen dynamic TUI apps (claude code, opencode, vim, htop).

Drop as many TerminalControl instances as you like into one app — each owns its own emulator engine and child process, so they run independently and resize with their layout slot.

Why from scratch

Generic terminal controls fail on real TUIs because they skip the query/response sequences — the app hangs waiting for a reply. This project implements the full contract that makes TUIs work:

  • Response channel — DA (ESC[c), DSR/CPR (ESC[6n), DECRQM — apps that ask get answered.
  • VT500 parser — canonical DEC ANSI state machine (Paul Williams), robust to split/garbled input.
  • Alternate screen (?1049h), truecolor (38;2;r;g;b) + 256-color, Unicode width (CJK/emoji = 2 cells, combining marks = 0), deferred autowrap, scroll regions, ICH/DCH/IL/DL/ECH, synchronized output, bracketed paste, SGR mouse reporting.
  • PTY backends — native ConPTY on Windows, forkpty on Linux/macOS.

Layout

Project Role
src/Terminal.Emulation Pure-C# engine: VT parser + screen/scrollback buffer. No UI, fully unit-tested.
src/Terminal.Pty Pseudo-terminal backends (ConPTY + Unix forkpty).
src/Terminal.Avalonia The TerminalControl: rendering, keyboard/mouse, clipboard, scrollbar.
samples/Terminal.Avalonia.Demo Three resizable terminals in splitters.
tests/Terminal.Emulation.Tests Engine + ConPTY smoke tests.

Install

dotnet add package Terminal.Avalonia

Three packages, always released together on one version number:

Package Take it when
Terminal.Avalonia You want the control. Pulls the other two.
Terminal.Pty You want ConPTY/forkpty behind one interface, with no UI.
Terminal.Emulation You want the VT engine alone — parsing a recorded session, testing, a renderer of your own.

On Windows, Terminal.Pty also lays conpty/<arch>/{conpty.dll,OpenConsole.exe} into your output and publish directories and runs sessions on that host rather than the in-box conhost.exe, which crashes on some TUI teardowns and takes the shell with it. Nothing to configure; IPtyConnection.HostDescription says which host a session actually got. To lay the files out yourself, set <TerminalPtyDeployConsoleHost>false</TerminalPtyDeployConsoleHost>.

Usage

var term = new TerminalControl { FontSize = 14 };
myGrid.Children.Add(term);

term.Start(new PtyOptions
{
    Command = OperatingSystem.IsWindows() ? "powershell.exe" : "/bin/bash",
    Columns = 80,
    Rows = 24,
});

The control sizes itself to its slot (columns/rows are derived from the font metrics) and forwards resizes to the child via SIGWINCH / ConPTY resize. Dispose (or detach from the visual tree) to kill the child and release the PTY.

Input & interaction

  • Full keyboard mapping incl. modifiers, function keys, application-cursor mode.
  • Mouse text selection (drag, double-click word, triple-click line) + SGR mouse reporting for TUIs; wheel scrolls history (or is reported to the app).
  • Ctrl+Shift+C / Ctrl+Shift+V copy & paste (bracketed-paste aware); Shift+PageUp/PageDown scroll.
  • Draggable scrollbar over the scrollback ring.
  • Bindable/stylable FontFamily, FontSize, Palette styled properties; cursor blinks when focused and shows a hollow block when not.

Roadmap

Prioritized gap analysis versus mature emulators (xterm.js, Windows Terminal, WezTerm, …) lives in docs/ROADMAP.md.

Build & test

dotnet build Terminal.Avalonia.slnx
dotnet test  Terminal.Avalonia.slnx
dotnet run --project samples/Terminal.Avalonia.Demo
build.cmd                       # build + test + pack into artifacts/

Releasing

python Deploy/publish.py --dry-run   # test, pack, stop short of pushing
python Deploy/publish.py             # test, bump the patch, build, pack, push all three

The version lives once, in Directory.Build.props. A ProjectReference packs as a PackageReference pinned to exactly that version, so the three go out together or a consumer resolves an engine its control was never built against. The API key goes in Deploy/.env (gitignored — copy .env.example).

License

MIT — see LICENSE. Terminal.Pty redistributes the MIT-licensed open-source console host from microsoft/terminal.

⚠️ Run the demo as a normal GUI app. Under a host whose stdout is redirected to a pipe (dotnet run captured by a tool, dotnet test), a console child can inherit that pipe instead of the pseudo console — a launcher artifact, not a bug in the control.

Product Compatible and additional computed target framework versions.
.NET 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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Terminal.Pty:

Package Downloads
Terminal.Avalonia

A lightweight, from-scratch terminal-emulator control for Avalonia UI. Hosts any shell and full-screen TUI apps (vim, htop, claude code, opencode): rendering, keyboard and mouse, selection and clipboard, scrollback, themes, OSC 8 hyperlinks. Many instances can run side by side — each owns its engine and its child process. On Windows it runs on the bundled open-source console host rather than the in-box conhost.exe.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.2.1 33 8/7/2026
0.2.0 32 8/7/2026
0.1.1 41 8/6/2026
0.1.0 49 8/6/2026