Table of Contents

Class SystemConsoleWrapper

Namespace
InteractiveReadLine.Abstractions
Assembly
InteractiveReadLine.dll

Presents System.Console through the IConsole interface. This default implementation originally existed to support unit testing. It is public so that callers can decorate or compose it to intercept output that read line operations write to the system console.

public class SystemConsoleWrapper : IConsole
Inheritance
SystemConsoleWrapper
Implements
Inherited Members

Properties

BufferHeight

Gets the height of the provider's buffer, measured in rows

public int BufferHeight { get; }

Property Value

int

BufferWidth

Gets the width of the provider's buffer, measured in columns

public int BufferWidth { get; }

Property Value

int

CursorLeft

Gets or sets the cursor's position from the left edge of the buffer

public int CursorLeft { get; set; }

Property Value

int

CursorTop

Gets or sets the cursor's position from the top of the buffer

public int CursorTop { get; set; }

Property Value

int

InputIsRedirected

Gets whether input comes from a redirected stream instead of an interactive console. Individual keypresses cannot be read from a redirected stream.

public bool InputIsRedirected { get; }

Property Value

bool

KeyAvailable

Gets whether a keypress is waiting, which lets callers wait for input without blocking on ReadKey.

public bool KeyAvailable { get; }

Property Value

bool

TreatControlCAsInput

Gets or sets whether Ctrl+C is delivered as an ordinary keypress rather than being treated as a signal to terminate the program.

public bool TreatControlCAsInput { get; set; }

Property Value

bool

Remarks

A read line operation enables this property so that a Ctrl+C key behavior can abandon the line, then restores the previous value when the operation finishes. Implementations without a system console can store the value without acting on it.

Methods

ReadKey()

Waits for a keypress and returns it without echoing it to the display.

public ConsoleKeyInfo ReadKey()

Returns

ConsoleKeyInfo

Information about the pressed key.

Write(FormattedChar)

Writes a single formatted character at the cursor, applying its colors.

public void Write(FormattedChar c)

Parameters

c FormattedChar

The character to write.

Write(FormattedText)

Writes formatted text at the cursor, applies each character's colors, and leaves the cursor after the written text.

public void Write(FormattedText text)

Parameters

text FormattedText

The text to write.

WriteLine(FormattedText)

Writes formatted text at the cursor followed by a newline, leaving the cursor at the start of the following row.

public void WriteLine(FormattedText text)

Parameters

text FormattedText

The text to write.