Skip to content
ConsoleMonster
Class

CommanderCommands

ConsoleMonster.Apps.Commander

Namespace
ConsoleMonster.Apps.Commander
Assembly
ConsoleMonster
Implements
IReadOnlyList<CommanderCommand> IReadOnlyCollection<CommanderCommand> IEnumerable<CommanderCommand> IEnumerable
Modifiers
sealed
Attributes
DefaultMember("Item")

The Commander's command registry: every command with its keys, label and availability, plus key routing (including type-to-search), the F-key bar and key bindings for the app host. F-keys follow Norton and Midnight Commander; each has an Alt+number alternative for terminals that swallow F-keys.

Inheritance

  • object
  • CommanderCommands

Usage

Explore 1 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 1

Constructors

public CommanderCommands(IEnumerable<CommanderCommand> commands) #

Creates a registry. Keys and key chords must be unique, and each key-bar slot holds one command.

Parameters

commands System.Collections.Generic.IEnumerable<ConsoleMonster.Apps.Commander.CommanderCommand> required
The commands.

Methods

public IReadOnlyList<KeyBinding> Bindings(CommanderContext context) #

The commands as key bindings for the app host's routing, footer and key map.

Parameters

context ConsoleMonster.Apps.Commander.CommanderContext required
The context their actions run in.

Returns

IReadOnlyList<KeyBinding> One binding per command that has keys.
public static CommanderCommands CreateDefault() #

The standard Commander commands.

Returns

CommanderCommands A new registry.
public bool Dispatch(InputEvent input, CommanderContext context) #

Routes a key: while a quick search is active, typing extends it, Backspace shortens it and Esc ends it; otherwise the bound command runs when available. Unbound printable characters start a quick search.

Parameters

input ConsoleMonster.Input.InputEvent required
The event.
context ConsoleMonster.Apps.Commander.CommanderContext required
The context.

Returns

bool Whether the key was handled; a bound but unavailable command still consumes its key.
public CommanderCommand? Find(string key) #

A command by key, or null.

Parameters

key string required
The key, such as copy.

Returns

CommanderCommand? The command.
public IEnumerator<CommanderCommand> GetEnumerator() #

Returns an enumerator that iterates through the collection.

Returns

IEnumerator<CommanderCommand> An enumerator that can be used to iterate through the collection.
public IReadOnlyList<CommanderKeyBarItem> KeyBar(CommanderContext context, bool alternatives = false) #

The ten F-key bar slots for the current context.

Parameters

context ConsoleMonster.Apps.Commander.CommanderContext required
The context.
alternatives bool = false optional
Whether to show the Alt+number keys, for terminals that swallow F-keys.

Returns

IReadOnlyList<CommanderKeyBarItem> Ten slots, numbered 1 to 10.
public CommanderCommand? Match(InputEvent input) #

The command bound to a key event, or null.

Parameters

input ConsoleMonster.Input.InputEvent required
The event.

Returns

CommanderCommand? The command.

Properties

public int Count { get; } #

The number of commands.

public CommanderCommand this[int index] { get; } #

A command by position.

Parameters

index int required
The position.