Back to Terminal Gui

Namespace Drivers

docfx/apispec/namespace-drivers.md

2.0.11.7 KB
Original Source

The Drivers namespace provides the platform abstraction layer enabling Terminal.Gui to run consistently across Windows, macOS, and Linux/Unix.

Key Types

  • IDriver - Main driver interface for terminal operations
  • DriverRegistry - Registry of available drivers with metadata
  • AnsiResponseParser - ANSI escape sequence parsing for input
  • AnsiKeyboardParser / AnsiMouseParser - Keyboard and mouse input parsing
  • EscSeqUtils - ANSI escape sequence constants and utilities
  • Cursor / CursorStyle - Terminal cursor management

Available Drivers

DriverPlatformDescription
windowsWindowsNative Win32 Console API with highest performance
unixUnix/Linux/macOSDirect syscalls with ANSI sequences
dotnetAllCross-platform using System.Console
ansiAllPure ANSI implementation, ideal for testing

Driver Selection

csharp
// Automatic (recommended)
app.Init ();  // Selects best driver for platform

// Explicit selection
app.Init (DriverRegistry.Names.ANSI);

// Via configuration
app.ForceDriver = DriverRegistry.Names.UNIX;
app.Init ();

See Also

Threading Model

The driver architecture uses a multi-threaded design:

  • Input Thread: Asynchronously reads console input without blocking the UI
  • Main UI Thread: Processes events, performs layout, and renders output

This separation ensures responsive input handling even during intensive UI operations.

Deep Dive

See the Cross-Platform Driver Model for comprehensive details.