Skip to content

nickprotop/ConsoleEx

ConsoleEx

ConsoleEx Logo

Documentation NuGet NuGet Downloads Build .NET License

SharpConsoleUI is a terminal GUI framework for .NET — not just a TUI library, but a full retained-mode GUI framework that targets the terminal as its display surface. Cross-platform (Windows, Linux, macOS).

The rendering engine follows the same architecture as desktop GUI frameworks like WPF and Avalonia: a Measure → Arrange → Paint layout pipeline, double-buffered compositing with occlusion culling, and a unified cell pipeline where ANSI never crosses layer boundaries. The terminal is just the rasterization target.

  • GUI-grade rendering engine — DOM-based layout, three-level dirty tracking, occlusion culling, adaptive Cell/Line/Smart rendering modes
  • Multi-window with per-window threads — each window updates independently without blocking others
  • Rich markup everywhere — just [bold red]text[/] and it works, no complex styling APIs
  • Any Spectre.Console widget works as a control — Tables, BarCharts, Trees, Panels — wrap any IRenderable
  • 30+ built-in controls — buttons, lists, trees, tables, text editors, dropdowns, menus, tabs, and more
  • Full Unicode & emoji support — CJK, Arabic, Hebrew, Thai, Devanagari, combining marks, variation selectors, ZWJ sequences — accurate wcwidth-based cell measurement
  • Compositor effects — PreBufferPaint/PostBufferPaint hooks for custom rendering, transitions, or even games
  • MVVM-compatible — all controls implement INotifyPropertyChanged; one-way and two-way data binding with Bind() / BindTwoWay()
  • Fluent builders for windows, controls, and layouts

Visit the project website: nickprotop.github.io/ConsoleEx

Browse examples with screenshots: EXAMPLES.md

Showcase

SharpConsoleUI Video Demo

Watch SharpConsoleUI in action on YouTube

SharpConsoleUI Demo

Rich controls, multiple windows, smooth gradients, real-time updates, and full-screen capabilities

Quick Start

dotnet add package SharpConsoleUI
using SharpConsoleUI;
using SharpConsoleUI.Builders;
using SharpConsoleUI.Drivers;

var windowSystem = new ConsoleWindowSystem(new NetConsoleDriver(RenderMode.Buffer));

var window = new WindowBuilder(windowSystem)
    .WithTitle("Hello World")
    .WithSize(50, 15)
    .Centered()
    .WithColors(Color.White, Color.DarkBlue)
    .Build();

windowSystem.NotificationStateService.ShowNotification(
    "Welcome", "Hello World!", NotificationSeverity.Info);

windowSystem.AddWindow(window);
windowSystem.Run();

Project Templates

dotnet new install SharpConsoleUI.Templates

dotnet new tui-app -n MyApp            # Starter app with list, button, notification
dotnet new tui-dashboard -n MyDash     # Fullscreen dashboard with tabs and live metrics
dotnet new tui-multiwindow -n MyApp    # Two windows with master-detail pattern

cd MyApp && dotnet run

Desktop Distribution (schost)

Package your app so end users can double-click to launch — no terminal knowledge required:

# Initialize terminal config for your project
schost init

# Launch in a configured terminal window (what the user will see)
schost run

# Package as portable zip + optional installer
schost pack --installer

schost opens your app in Windows Terminal (or Linux terminal emulator) with custom title, font, colors, and size. The app uses the real terminal — no compatibility layer. See the schost guide for details.

Controls Library (30+)

Category Controls
Text & Display MarkupControl, FigleControl, RuleControl, SeparatorControl, SparklineControl, BarGraphControl, LogViewerControl
Input ButtonControl, CheckboxControl, PromptControl, DropdownControl, MultilineEditControl
Data ListControl, TreeControl, TableControl (interactive DataGrid with virtual data, sorting, editing), HorizontalGridControl
Navigation MenuControl, ToolbarControl, TabControl, NavigationView
Layout ColumnContainer, SplitterControl, ScrollablePanelControl, PanelControl
Drawing CanvasControl, ImageControl (PNG/JPEG/BMP/GIF/WebP/TIFF via ImageSharp)
Advanced SpectreRenderableControl (wraps any Spectre.Console IRenderable), ProgressBarControl, TerminalControl

See the Controls Reference for detailed documentation on each control.

Key Features

Independent Window Threads

Each window can run with its own async thread, enabling true multi-threaded UIs:

var clockWindow = new WindowBuilder(windowSystem)
    .WithTitle("Digital Clock")
    .WithSize(40, 12)
    .WithAsyncWindowThread(async (window, ct) =>
    {
        while (!ct.IsCancellationRequested)
        {
            var time = window.FindControl<MarkupControl>("time");
            time?.SetContent(new List<string> { $"[bold cyan]{DateTime.Now:HH:mm:ss}[/]" });
            await Task.Delay(1000, ct);
        }
    })
    .Build();

Fluent Builders with Window Access

Event handlers include a window parameter for cross-control interaction via FindControl<T>():

window.AddControl(Controls.Button("Submit")
    .OnClick((sender, e, window) =>
    {
        var input = window.FindControl<PromptControl>("nameInput");
        var status = window.FindControl<MarkupControl>("status");
        status?.SetContent($"[green]Submitted:[/] {input?.Text}");
    })
    .Build());

Built-in Services

// Notifications
windowSystem.NotificationStateService.ShowNotification("Title", "Message", NotificationSeverity.Info);

// Debug logging (file-based, never console)
// export SHARPCONSOLEUI_DEBUG_LOG=/tmp/consoleui.log
windowSystem.LogService.LogAdded += (s, entry) => { /* handle */ };

// State services: Focus, Modal, Window, Theme, Cursor, etc.
windowSystem.FocusStateService.FocusedWindow;
windowSystem.ModalStateService.HasModals;

Themes & Plugins

// Built-in themes with runtime switching
windowSystem.ThemeRegistry.SetTheme("ModernGray");

// Plugin system
windowSystem.PluginStateService.LoadPlugin<DeveloperToolsPlugin>();

Compositor Effects

Direct buffer access for custom backgrounds, post-processing, and transitions:

window.Renderer.PreBufferPaint += (buffer, dirty, clip) =>
{
    // Render custom background before controls
};

window.Renderer.PostBufferPaint += (buffer, dirty, clip) =>
{
    // Apply post-processing effects after controls
};

Architecture

┌─────────────────────────────────────────────────────────────┐
│  Application Layer (Your Code)                              │
│  └── Window Builders, Event Handlers, Controls              │
├─────────────────────────────────────────────────────────────┤
│  Framework Layer                                            │
│  ├── Fluent Builders, State Services, Logging, Plugins      │
├─────────────────────────────────────────────────────────────┤
│  Layout Layer                                               │
│  ├── DOM Tree (LayoutNode) — Measure → Arrange → Paint      │
├─────────────────────────────────────────────────────────────┤
│  Rendering Layer                                            │
│  ├── Multi-pass compositor, occlusion culling, portals      │
├─────────────────────────────────────────────────────────────┤
│  Buffering Layer                                            │
│  ├── CharacterBuffer → ConsoleBuffer → adaptive diff output │
├─────────────────────────────────────────────────────────────┤
│  Driver Layer                                               │
│  ├── NetConsoleDriver (production) / Headless (testing)     │
│  └── Raw libc I/O (Unix) / Console API (Windows)            │
└─────────────────────────────────────────────────────────────┘

The native markup parser converts [bold red]text[/] directly into typed Cell structs — no ANSI intermediate format. Everything flows as cells through CharacterBuffer → ConsoleBuffer → terminal output.

Projects Using SharpConsoleUI

ServerHub ServerHub
TUI server monitoring and management dashboard for Linux. Real-time metrics, logs, and remote control from your terminal with 14 bundled widgets.
LazyNuGet LazyNuGet
TUI for managing NuGet packages across .NET solutions. Search, update, and manage dependencies with multi-source support and dependency trees.
LazyDotIDE LazyDotIDE
Lightweight console-based .NET IDE with LSP IntelliSense, built-in terminal, and git integration. Works over SSH, in containers, anywhere you have a console.

Using SharpConsoleUI in your project? Open a PR to add it to this list!

Getting Started

git clone https://github.com/nickprotop/ConsoleEx.git
cd ConsoleEx
dotnet build
dotnet run --project Examples/DemoApp

Documentation

Guide Description
Examples Gallery All examples with screenshots
Fluent Builders WindowBuilder and control builder APIs
Controls Reference Complete guide to all 30+ UI controls
Markup Syntax Markup tags, colors, decorations
Built-in Dialogs File pickers, folder browsers
Configuration System configuration reference
Themes Built-in themes, custom themes, runtime switching
State Services Window state, focus, modal, notification services
Plugins Plugin architecture and development
Compositor Effects Buffer manipulation and visual effects
DOM Layout System Layout engine internals
Rendering Pipeline Rendering architecture details
Portal System Floating portals and overlay system
Status System Status bars, window task bar, Start Menu
Desktop Host (schost) Launch, package, and distribute TUI apps as desktop apps

API Reference: nickprotop.github.io/ConsoleEx

License

MIT License — see LICENSE.txt.

Acknowledgments

Development Notes

SharpConsoleUI was initially developed manually with core windowing functionality and double-buffered rendering. The project evolved to include modern features (DOM-based layout system, fluent builders, plugin architecture, theme system) with AI assistance. Architectural decisions and feature design came from the project author, while AI generated code implementations based on those decisions.


Made for the .NET console development community

About

SharpConsoleUI — A .NET 8+ console windowing system with overlapping windows, 30+ controls, embedded terminal emulator, canvas drawing, and async per-window threads.

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages