Table of Contents

Class CommandLineState

Namespace
MiniTui
Assembly
MiniTui.dll

A text field with command history: Enter submits, ↑/↓ recall history, Esc clears a selection, or else the text (§8.4, 1.x spec §10.3).

public sealed class CommandLineState : TextFieldState
Inheritance
CommandLineState
Inherited Members

Constructors

CommandLineState()

Create a state with empty history.

public CommandLineState()

CommandLineState(IEnumerable<string>)

Create a state seeded with history (copied), oldest first.

public CommandLineState(IEnumerable<string> history)

Parameters

history IEnumerable<string>

Properties

History

Submitted lines, oldest first.

public ImmutableList<string> History { get; set; }

Property Value

ImmutableList<string>

MaxHistory

The most entries History keeps; older ones are dropped. Default 100.

public int MaxHistory { get; set; }

Property Value

int

Methods

HandleKey(ConsoleKeyInfo)

Handle an editing key (§8.4 and 1.x spec §10.3): text, ← → Home End, Ctrl+← →, Shift with those to select, Backspace, Delete, Ctrl+Backspace / Ctrl+W (delete word), Ctrl+U (delete to start), Ctrl+K (delete to end), Ctrl+A (select all), Ctrl+C / Ctrl+X (copy and cut, only with a selection), Ctrl+V (paste the clipboard), Ctrl+Z (undo), Ctrl+Y (redo) and Esc (clear the selection, only with one).

public override bool HandleKey(ConsoleKeyInfo key)

Parameters

key ConsoleKeyInfo

Returns

bool

True if the key was an editing key.

HandleKey(ConsoleKeyInfo, out ParsedCommand?)

Handle a key. Enter submits non-blank text: it's added to History (unless it repeats the last entry), the field is cleared, and submitted is the parsed command (null if the text isn't a :command).

public bool HandleKey(ConsoleKeyInfo key, out ParsedCommand? submitted)

Parameters

key ConsoleKeyInfo
submitted ParsedCommand

Returns

bool

True if the key was handled.