Table of Contents

Class RawMode

Namespace
Retro.Crt.Input
Assembly
Retro.Crt.dll

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.

public static class RawMode
Inheritance
RawMode
Inherited Members

Remarks

On Linux and macOS this calls tcgetattr / tcsetattr on stdin (fd 0). On Windows it flips the console-input mode bits via SetConsoleMode with ENABLE_VIRTUAL_TERMINAL_INPUT so stdin produces ANSI escape sequences exactly like Unix — ReadConsoleInputW is intentionally not used.

The default strips signal generation (ISIG on Unix, ENABLE_PROCESSED_INPUT on Windows): Ctrl-C arrives as a regular KeyEvent for the app to handle. Pass keepSignals: true to keep SIGINT live — the safer choice when you don't want a hung app to swallow the user's Ctrl-C.

Disposing restores the previous terminal state. A ProcessExit handler is registered lazily on first use so the user's shell isn't left in raw mode if the process exits without disposing the scope.

Methods

Enter(bool)

Enter raw mode. Returns a scope that restores the previous terminal state on disposal. Throws InvalidOperationException if raw mode is already active — nesting is not supported, since terminal state is a single global resource.

public static IDisposable Enter(bool keepSignals = false)

Parameters

keepSignals bool

Returns

IDisposable