Table of Contents

Interface IConsole

Namespace
InteractiveReadLine.Abstractions
Assembly
InteractiveReadLine.dll

Defines a provider for a buffer backed, console-like interface. Intended to create a seam between the actual System.Console instance and the higher level behaviors, it can also be used to wrap any character buffer interface with a moving cursor.

public interface IConsole

Properties

BufferHeight

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

int BufferHeight { get; }

Property Value

int

BufferWidth

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

int BufferWidth { get; }

Property Value

int

CursorLeft

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

int CursorLeft { get; set; }

Property Value

int

CursorTop

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

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.

bool InputIsRedirected { get; }

Property Value

bool

KeyAvailable

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

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.

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.

ConsoleKeyInfo ReadKey()

Returns

ConsoleKeyInfo

Information about the pressed key.

Write(FormattedChar)

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

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.

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.

void WriteLine(FormattedText text)

Parameters

text FormattedText

The text to write.