XenoAtom.Terminal is the foundation underneath XenoAtom.Terminal.UI. It is a modern replacement for System.Console
designed for TUI/CLI apps: safe output, terminal-native capabilities, unified input events, and deterministic testing.
XenoAtom.Terminal is a terminal API, not a widget framework. Terminal.UI provides the widget/layout layer.
System.Console)?XenoAtom.Terminal keeps a familiar console-like surface (Write, ReadKey, cursor, colors), while adding the
capabilities that are hard to do correctly and portably with System.Console:
XenoAtom.AnsiTerminal is initialized lazily on first use, or explicitly via Terminal.Open():
using XenoAtom.Terminal;
using var session = Terminal.Open();
Terminal.WriteLine("Hello from XenoAtom.Terminal");
Basic output:
using XenoAtom.Terminal;
Terminal.WriteLine("Hello");
Atomic output (prevents interleaving with concurrent writes):
Terminal.WriteAtomic(w =>
{
w.Foreground(ConsoleColor.DarkGray);
w.Write("[");
w.Write(DateTimeOffset.UtcNow.ToString("HH:mm:ss.fff"));
w.Write("] ");
w.ResetStyle();
w.Write("message\n");
});
Markup output (powered by XenoAtom.Ansi):
Terminal.WriteMarkup("[bold green]Hello[/] [gray]world[/]!");
See:
Terminal behavior depends on the host (Windows Console vs terminal emulator vs CI logs). You can inspect capabilities:
Terminal.WriteLine($"Ansi={Terminal.Capabilities.AnsiEnabled}, Color={Terminal.Capabilities.ColorLevel}");
For terminal emulator recommendations and color troubleshooting (truecolor, tmux/SSH, WSL), see:
If you need deterministic behavior (e.g. tests), initialize Terminal with an explicit backend.
XenoAtom.Terminal supports a unified event stream (keyboard, resize, mouse/paste when available). This is a better fit for TUIs than mixing multiple platform-specific input APIs.
Avoid mixing System.Console input APIs with XenoAtom.Terminal input APIs in the same app.
Example: consuming the event stream (for custom TUIs or advanced integrations):
using XenoAtom.Terminal;
await foreach (var ev in Terminal.ReadEventsAsync())
{
Terminal.WriteLine(ev.ToString());
}
XenoAtom.Terminal includes a rich ReadLine editor (history, completion, clipboard, rendering), with both sync and async APIs:
using XenoAtom.Terminal;
var line = Terminal.ReadLine(new TerminalReadLineOptions
{
PromptMarkup = () => "[bold]Name:[/] ",
});
Highlights:
Terminal.UI builds higher-level prompt controls on top of Terminal's live hosting; see:
Terminal.Live)Terminal can run against a virtual/in-memory backend, which makes it suitable for deterministic tests. Terminal.UI tests use the same idea at the UI layer (render to buffers and diff).
Terminal.UI integrates as extension members on Terminal:
Terminal.Write(Visual) - render onceTerminal.Live(Visual, onUpdate) - inline live region (mouse reporting is disabled by default)Terminal.Run(Visual, onUpdate) - fullscreen app (alternate screen)See: