TermBlade

Razor-sharp Terminal UIs for .NET 10

A cell-based rendering engine with ANSI escape sequence support, styled text, a rope-backed edit buffer with full undo/redo, Razor component hosting, and a plugin architecture.

terminal
$ dotnet add package TermBlade.Core
info : Adding PackageReference for 'TermBlade.Core'...
info : Package 'TermBlade.Core' installed successfully.

Start where you are

A clear path from install to application

Choose a guided tutorial, a task-focused recipe, or a runnable repository example. The component gallery remains the complete visual reference.

Features

🎨

Cell-Based Rendering

2D terminal cell grid with text, borders, blitting, and alpha blending. Full ANSI escape sequence support with true-color and 256-color palettes.

📝

Rope-Backed Editor

High-performance text editing with a rope data structure. Full cursor navigation, insert/delete operations, and unlimited undo/redo.

⚡

Diff-Based Renderer

Only redraws cells that have changed between frames. Alternate screen support for clean terminal management.

🧩

Plugin Architecture

Extensible plugin system with registration and lifecycle management. Build and share custom components.

🔧

Razor Component Host

Use familiar Razor syntax to build terminal UIs. Component-based architecture with data binding and event handling.

🎯

Rich Renderables

Built-in components: Box, Text, Input, Select, TreeView, Slider, ScrollBox, Markdown, Code highlighting, Diff viewer, and more.

Quick Start

TermBlade offers two approaches to build terminal UIs. Use TermBlade.Core for low-level, imperative drawing with full control over cells, colors, and ANSI sequences. Use TermBlade.Razor for a declarative, component-based experience with familiar Razor syntax.

Option A — Core API

1 Install the package

dotnet add package TermBlade.Core

2 Draw your first UI

using TermBlade.Core.Ansi;
using TermBlade.Core.Buffer;

using var buf = CellBuffer.Create(60, 20);
var bg     = Rgba.FromInts(0,   0,   0);
var fg     = Rgba.FromInts(255, 255, 255);
var accent = Rgba.FromInts(0,   200, 255);

buf.Clear(bg);
buf.DrawBox(0, 0, 60, 20, accent, bg, BorderStyle.Rounded, BorderSides.All,
            fill: true, title: " My App ");
buf.DrawText("Hello from TermBlade!", 4, 3, fg, bg);

3 Build & run

dotnet build
dotnet run

Option B — Razor Components

1 Install the package

dotnet add package TermBlade.Razor

2 Create a component (MyApp.razor)

<Box Width="100%" Height="100%" Border="true" BorderStyle="rounded" BorderColor="#00c8ff" BackgroundColor="#000000" Title=" My App ">
    <Text Content="Hello from TermBlade!" Fg="#ffffff" />
</Box>

3 Host and run (Program.cs)

using Microsoft.Extensions.Hosting;
using TermBlade.Razor.Hosting;

var host = Host.CreateDefaultBuilder(args)
    .UseTermBladeRazor<MyApp>()
    .Build();

await host.RunAsync();
dotnet run

Key Types

TypeDescription
RgbaPacked color: RGB, ANSI-256 indexed, or terminal-default intent
CellBuffer2D terminal cell grid with text, borders, blitting, alpha blend
TextBufferStyled text storage (read-only display)
EditBufferRope-backed editor: cursor, insert/delete, undo/redo
RendererDiff-based ANSI terminal renderer with alternate-screen support
SyntaxStyleNamed style definitions with priority-aware merging
EventEmitterSimple on/off/once/emit event bus
PluginRegistryIPlugin registration and lifecycle

Open the full API reference

Project Structure

src/TermBlade.Core/          # Core library (NuGet package)
  Ansi/                      # Rgba, AnsiCodes, TextAttributes, ColorIntent
  Buffer/                    # CellBuffer, Cell, BorderStyle
  Text/                      # TextBuffer, EditBuffer, Rope, StyledText
  Rendering/                 # Renderer (diff-based, alternate screen)
  Syntax/                    # SyntaxStyle, StyleDefinition
  Events/                    # EventEmitter
  Plugins/                   # IPlugin, PluginRegistry

src/TermBlade.Razor/         # Razor host + component wrappers
src/TermBlade.FileManager/   # Global dotnet tool: file manager
src/TermBlade.CsvViewer/     # Global dotnet tool: CSV viewer

tests/TermBlade.Tests/       # xUnit test suite

samples/TermBlade.Samples/          # Sample console applications
samples/TermBlade.Razor.Samples/    # Razor-hosted sample applications
samples/TermBlade.Gallery/          # Interactive component gallery

Run Samples

$ dotnet run --project samples/TermBlade.Samples -- layout   # simple box layout
$ dotnet run --project samples/TermBlade.Samples -- styled   # text attributes
$ dotnet run --project samples/TermBlade.Samples -- editor   # edit buffer demo
$ dotnet run --project samples/TermBlade.Samples -- scroll   # scrolling content
$ dotnet run --project samples/TermBlade.Samples -- input    # keyboard input
$ dotnet run --project samples/TermBlade.Samples -- treeview # tree view demo
$ dotnet run --project samples/TermBlade.Razor.Samples -- treeview # razor tree view demo
$ dotnet run --project samples/TermBlade.Razor.Samples -- chess    # chess game (Razor)
$ dotnet run --project src/TermBlade.Chess                         # chess standalone app
$ dotnet run --project samples/TermBlade.Gallery   # interactive component gallery

Install Tools

$ dotnet tool install --global TermBlade.FileManager
$ tbfm ./src
$ dotnet tool install --global TermBlade.CsvViewer
$ tbcsv ./data.csv # Razor-hosted, less-like CSV table viewer

Showcase

pwsh in TermBlade.Chess
TermBlade Chess — terminal chess game rendered in TermBlade.Razor
Chess game — a fully playable chess app built with TermBlade.Razor. Features a cell-based board renderer, move history panel, material tracking, bot opponent toggle, inline help overlay, and mouse support — all in the terminal.
$ dotnet run --project src/TermBlade.Chess