Table of Contents

Namespace Retro.Crt.Input

Classes

InputParser

Pure parsers for terminal input streams: ANSI key escape sequences, SGR-encoded mouse reports (mode 1006), control bytes, and printable chars. Stateless — pass the unread tail of your input buffer in, advance by the returned consumed count on success.

RawMode

Put the terminal into raw mode for the duration of the returned scope: no line buffering, no echo, no IEXTEN editing. Pairs with TerminalInput to actually consume the bytes.

TerminalInput

Read decoded InputEvents from stdin. Pair with RawMode so the terminal actually delivers bytes instead of cooked, line-buffered input.

Structs

InputEvent

Tagged-union input event: read Kind first, then access the slot the discriminator names. Key and mouse events are zero-allocation; paste events carry a string for the pasted contents and so allocate one reference per event.

KeyEvent

One decoded key press. Key identifies what was hit; Glyph carries the character when Key is Glyph (otherwise '\0'); Modifiers reports any held modifiers the terminal surfaced.

MouseEvent

One decoded mouse event. X / Y are 1-based screen coordinates as the terminal reports them — same convention as Crt.GotoXY(column, row).

Enums

InputEventKind

Discriminator on InputEvent. None represents an "empty" input event (the default value of the struct).

InputParseStatus

Outcome of a parse attempt — see TryParseEvent(ReadOnlySpan<char>, out InputEvent, out int) and friends.

Key

Logical key identifiers, decoded from ANSI escape sequences and control-byte conventions. Glyph carries the actual printable when Key is Glyph.

KeyModifiers

Modifier keys held while a key was generated. Encodes the standard xterm modifier byte (1 + (Shift?1:0) + (Alt?2:0) + (Ctrl?4:0)) after the -1 normalization, plus a flag for the rare Meta / Super key reported by some terminals.

MouseButton

Mouse button reported by the terminal. None covers motion events with no button held.

MouseEventKind

What the user did with the mouse. Move is reported in any-event tracking modes, Drag in motion-while-pressed modes; both depend on which mouse mode the terminal is in.