Table of Contents

Interface IKeyBehaviorTarget

Namespace
InteractiveReadLine.KeyBehaviors
Assembly
InteractiveReadLine.dll

Provides the unified target of key behaviors, exposing a standard amount of state which the behavior method can act upon

public interface IKeyBehaviorTarget

Properties

CursorPosition

Gets or sets the integer position of the cursor. Cannot be set before the beginning or after the end of the TextBuffer.

int CursorPosition { get; set; }

Property Value

int

CutBuffer

Gets the text accumulated by the most recent run of cut operations. The paste behavior inserts this text at the cursor. The value is empty when nothing has been cut.

string CutBuffer { get; }

Property Value

string

Remarks

The buffer belongs to a single read line operation and does not carry over to the next one. It is populated through CutForward and CutBackward, which accumulate consecutive cuts into one piece of text that can be pasted.

ReceivedKey

Gets the ConsoleKey which was received for the current request

ConsoleKeyInfo ReceivedKey { get; }

Property Value

ConsoleKeyInfo

TextBuffer

Gets the string buffer which holds the current readline text which is being edited by the user

StringBuilder TextBuffer { get; }

Property Value

StringBuilder

Methods

AutoCompleteNext()

Invokes the auto-complete's "next" functionality, which substitutes in the next suggestion

void AutoCompleteNext()

AutoCompletePrevious()

Invokes the auto-complete's "previous" functionality, which substitutes in the previous suggestion

void AutoCompletePrevious()

Cancel()

Tells the ReadLine handler to abandon the current line and discard the entered text. This matches conventional Ctrl+C behavior: the handler records nothing in history and completes without an error.

void Cancel()

CutBackward(string)

Records text removed from behind the cursor, placing it at the front of the cut buffer.

void CutBackward(string text)

Parameters

text string

The text that was removed from the line.

Remarks

A behavior that removes text from behind the cursor, such as cutting to the start of the line or cutting the previous word, should report it here. Cutting three words backward one after another therefore leaves the three words in the buffer in their original order.

CutForward(string)

Records text removed from in front of the cursor, placing it at the end of the cut buffer.

void CutForward(string text)

Parameters

text string

The text that was removed from the line.

Remarks

Cut text is stored in its original order on the line, so a run of cuts can be pasted back as the original text. A behavior that removes text in front of the cursor, such as cutting to the end of the line, should report it here.

EndOfInput()

Tells the ReadLine handler that the user has signaled the end of input, which is what Ctrl+D on an empty line means to a shell. The line is discarded, and the caller is told that no further input is coming.

void EndOfInput()

Finish()

Tells the readline handler to finish this line of input and return it

void Finish()

GetTextTokens()

Gets the tokenized text buffer when the handler configuration has a lexer.

TokenizedLine? GetTextTokens()

Returns

TokenizedLine

The tokenized line, or null when the configuration has no lexer.

HistoryNext()

Invokes the history's "next" functionality, which replaces the entire line with the next element in the history collection. If the last history element has been reached, the previously entered LineState will be reverted.

void HistoryNext()

HistoryPrevious()

Invokes the history's "previous" functionality, which replaces the entire line with the previous element in the history collection.

void HistoryPrevious()

InsertText(FormattedText)

Inserts text to the console out in the spot where the current read line input is, then immediately re-displays the line input on the next row. Use this to interrupt the user with a message or information while the ReadLine is still being used

void InsertText(FormattedText text)

Parameters

text FormattedText

The text to write to the console, a newline char will be added automatically