Class AnsiInput
Pure ANSI Driver with VT Input Mode on Windows and termios raw mode on Unix/Mac.
public class AnsiInput : InputImpl<char>, ITestableInput<char>, IInput<char>, IDisposable
- Inheritance
-
AnsiInput
- Implements
- Inherited Members
Remarks
IInput<TInputRecord> implementation that uses a character stream for pure ANSI input. Supports both test injection via ITestableInput<TInputRecord> and real console reading.
This driver reads raw bytes from different sources depending on platform and processes them as ANSI escape sequences. It configures the terminal for proper ANSI input:
-
Unix/Mac - Uses Terminal.Gui.Drivers.UnixRawModeHelper to disable echo and line buffering (raw mode).
Uses
poll()andread()syscalls for non-blocking input via Terminal.Gui.Drivers.UnixIOHelper. -
Windows - Uses Terminal.Gui.Drivers.WindowsVTInputHelper to enable Virtual Terminal Input mode.
This mode converts console input to ANSI escape sequences that can be read via
ReadFileAPI. Mouse events, keyboard input, etc. are all provided as VT sequences.
Implementation Notes:
-
Windows: Uses
ReadFileAPI (via Terminal.Gui.Drivers.WindowsVTInputHelper) to read ANSI sequences -
Unix/Mac: Uses Terminal.Gui.Drivers.UnixIOHelper for
poll()andread()syscalls - Throttled by Run(CancellationToken) (20ms delay between polls)
- Suitable for both production use and unit testing
Architecture:
Reads raw bytes from platform-specific APIs, converts them to UTF-8 characters, and feeds them to Terminal.Gui.Drivers.AnsiResponseParser<TInputRecord> which extracts keyboard events, mouse events (SGR format), and terminal responses.
Constructors
- AnsiInput()
Creates a new ANSIInput.
Methods
- Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
- InjectInput(char)
Adds an input record that will be returned by Peek/Read for testing.
- Peek()
When implemented in a derived class, returns true if there is data available to read from console.