Retro.Crt

Tiny, zero-dep, AOT-clean Pascal-CRT charm for .NET CLIs.

Pascal CRT-Unit verbs (TextColor, GotoXY, ClrScr, ClrEol, Bell), truecolor with graceful 256-color, 16-color, and NO_COLOR fallback, nine built-in themes (six era-faithful retro presets and three modern dark themes), and a small set of curated output blocks — framed banners, in-place progress bars, animated spinners, aligned tables, interactive prompts, a five-level logger, and a typewriter that fades characters in. Plus alt-screen takeover for vim/less-style apps.

dotnet add package Retro.Crt
using Retro.Crt;

Crt.TextColor(Color.LightCyan);
Crt.WriteLine("system online.");

using (Crt.WithStyle(Color.Yellow, bold: true))
    Crt.WriteLine("> ready.");

Targets net10.0. No third-party dependencies.

Why

Spectre.Console is great, but it does not trim or AOT cleanly. For a small CLI that publishes trim- or AOT-safe — a launcher, a build tool, a one-shot installer — pulling Spectre in noticeably bloats the output and breaks the trim pass. Retro.Crt is the small, opinionated alternative for tools that want curated colored output, themed widgets, and nothing more elaborate than a table.

Comparison

Retro.Crt Spectre.Console Pastel Crayon
Trim / AOT clean
Runtime dependencies 0 many 0 0
Truecolor
256-color quantization
Pascal-flavoured verbs
Framed banner
Progress bar ✅ (single) ✅ (multi/live)
Spinner
Aligned tables ✅ (basic) ✅ (rich)
Interactive prompts ✅ (3 verbs) ✅ (rich)
Themes ✅ (9 presets)
Trees / forms / panels
Live regions / layout
Markup language
Alt-screen takeover
Built-in logger ✅ (tiny)

If you need trees, forms, panels, live layouts, or a markup language — use Spectre.Console. If your CLI publishes trim- or AOT-safe and you don't want a single console UI library to be the thing that breaks that — and you'd settle for a charming splash screen, themed output, a few log levels, a progress bar, a spinner, simple tables, and three flavours of prompt — this library.

Demos

Three tiers under the repo on GitHub — clone and run any of them:

# samples/ — small single-feature tours
dotnet run --project samples/Retro.Crt.Demo            # 25 s feature tour
dotnet run --project samples/Retro.Crt.Themes.Demo     # all 9 themes side by side
dotnet run --project samples/Retro.Crt.Matrix.Demo     # "Wake up, Neo" cinematic
dotnet run --project samples/Retro.Crt.Boot.Demo       # fake AMIBIOS POST + DOS prompt
dotnet run --project samples/Retro.Crt.Capabilities.Demo   # color-depth fallback
dotnet run --project samples/Retro.Crt.AltScreen.Demo  # alt-screen takeover, restores your shell
dotnet run --project samples/Retro.Crt.ScreenBuffer.Demo   # cell-grid + diff renderer
dotnet run --project samples/Retro.Crt.Input.Demo      # live input event probe
dotnet run --project samples/Retro.Crt.Tui.Demo        # Tui widget tour

# games/ — five ASCII games on the core's ScreenBuffer + RawMode
dotnet run --project games/snake -c Release
dotnet run --project games/life -c Release
dotnet run --project games/matrix-rain -c Release
dotnet run --project games/invaders -c Release
dotnet run --project games/tetris -c Release

# apps/ — substantial tech demos
dotnet run --project apps/commander -c Release         # Norton-Commander-Lite

Public surface at a glance

Core

  • Crt — Pascal verbs (TextColor, GotoXY, ClrScr, ClrEol, Bell, PaintBackground), WithStyle / UseTheme / WithSink / UseAlternateScreen scopes, capability accessors (ColorEnabled, Depth, IsInteractive, WindowWidth, CursorLeft, Sink).
  • Color — DOS palette, truecolor, xterm-256 via Color.Indexed256, depth-aware quantization through Color.For, hex / name parsing.
  • ColorModeTruecolor / Standard16 / Xterm256.
  • ColorDepth — what the terminal can render: None / Standard16 / Xterm256 / Truecolor.

Output blocks

  • Banner — framed Box (with BoxAlign) and per-line Gradient.
  • ProgressBar — single-line redraw, cursor-anchored, Crt.FillWidth for terminal-width sizing.
  • Spinner — animated single-line spinner; pick a frame set via SpinnerStyle.
  • Table — aligned-column tables with TableBorder box / borderless modes.
  • Typewriter — character-by-character reveal with optional cursor (TypewriterCursor) and fade (TypewriterFade). Blink for pause beats, async + cancellation supported.
  • PromptConfirm, Ask, arrow-key Select.
  • Log — semantic logger with LogLevel tags, MinLevel filter, OutSink / ErrSink overrides, scoped UseSink.

Theming

  • Theme — record struct with six slots (Foreground, Accent, Muted, Success, Warn, Error). Themes do not own a background — set one explicitly per call when you need it.
  • Themes — built-in palettes: retro (Dos, AmberCrt, GreenCrt) and modern dark (Midnight, Slate, Twilight).
  • Apply with Crt.UseTheme(Themes.AmberCrt) — widgets fall back to the theme's slots when no explicit color is passed.

Diagnostics

  • DiagnosticsCapture() returns a TerminalReport with ColorDepth, IsInteractive, encoding, env vars; ToString() gives a one-line dense summary for support tickets.

Cell grid + input (Stage 3 + 2a/2b)

  • ScreenBuffer + ScreenRenderer — stateful cell grid (Cell per coordinate, each Glyph + Fg + Bg + CellAttrs) plus a minimal-ANSI diff renderer that emits cursor moves + SGR + chars only for cells that actually changed. Pair with Crt.UseAlternateScreen() for flicker-free game loops.
  • Retro.Crt.InputKeyEvent with KeyModifiers, MouseEvent, InputEvent tagged union; stateless InputParser for ANSI/CSI/SS3 decode; RawMode.Enter() for per-OS termios + SetConsoleMode; TerminalInput.ReadEvent / TryReadEvent / WaitForEvent for the actual stdin pump.
  • Crt.UseMouse() / Crt.UseBracketedPaste() / Crt.UseHiddenCursor() — IDisposable scopes for SGR mouse mode, paste envelopes, and cursor hiding.

Retro.Crt.Tui

Separate package on top of the core's ScreenBuffer + diff renderer + input parser, for full-screen DOS-style UIs (Midnight Commander / Turbo Vision style). Application runs the alt-screen + raw + mouse + diff-redraw event loop; View and Container are the bases; widgets include Panel, Label, Button, LogViewer, TextBox, Menu, Dialog (with Dialog.MessageBox helper), StackPanel, plus an abstract ScrollViewer. Layout.Split / Layout.Dock are span-based zero-alloc geometry helpers.

dotnet add package Retro.Crt.Tui

Browse the full namespace in the API reference.

More

License

MIT.