Skip to main content

ViewCommand class

Namespace: Arlecchino.Commands · Assembly: Arlecchino

A key a screen reacts to, declared as data rather than hidden in a switch. That is what lets the palette list it, the hints box label it, and the conflict check see it.

public sealed class ViewCommand

Constructors

MemberSummary
ViewCommand()

Properties

MemberSummary
BindingKey that runs the command. Checked before the screen's own key handling.
IsEnabledWhether the command can run now. A disabled command is skipped, and its key carries on as if nothing had claimed it; bind it to nothing instead to hold the key.
LabelName shown in the palette and the hints box; a delegate, so it can be translated.
RunWhat the command does.

Methods

MemberSummary
For(KeyBinding, Func<string>, Action)A command that does something and stays on the screen.
For(ConsoleKey, Func<string>, Action)A command on a plain key that does something and stays on the screen.
Navigating(ConsoleKey, Func<string>, Func<ViewRoute>)A command on a plain key that navigates somewhere.

Constructors in detail

ViewCommand()

Obsolete

Constructors of types with required members are not supported in this version of your compiler.

public ViewCommand();

Properties in detail

Binding

public KeyBinding Binding { get; init; }

Key that runs the command. Checked before the screen's own key handling.

Type KeyBinding

IsEnabled

public Func<bool> IsEnabled { get; init; }

Whether the command can run now. A disabled command is skipped, and its key carries on as if nothing had claimed it; bind it to nothing instead to hold the key.

Type Func<TResult><bool>

Label

public Func<string> Label { get; init; }

Name shown in the palette and the hints box; a delegate, so it can be translated.

Type Func<TResult><string>

Run

public Func<ViewRoute> Run { get; init; }

What the command does.

Type Func<TResult><ViewRoute>

Methods in detail

For(KeyBinding, Func<string>, Action)

public static ViewCommand For(KeyBinding binding, Func<string> label, Action run);

A command that does something and stays on the screen.

Parameters

NameTypeDescription
bindingKeyBindingKey that runs it.
labelFunc<TResult><string>Name shown to the user.
runActionWhat to do.

Returns ViewCommand — The command.

For(ConsoleKey, Func<string>, Action)

public static ViewCommand For(ConsoleKey key, Func<string> label, Action run);

A command on a plain key that does something and stays on the screen.

Parameters

NameTypeDescription
keyConsoleKeyKey that runs it.
labelFunc<TResult><string>Name shown to the user.
runActionWhat to do.

Returns ViewCommand — The command.

public static ViewCommand Navigating(ConsoleKey key, Func<string> label, Func<ViewRoute> run);

A command on a plain key that navigates somewhere.

Parameters

NameTypeDescription
keyConsoleKeyKey that runs it.
labelFunc<TResult><string>Name shown to the user.
runFunc<TResult><ViewRoute>What to do; the route it returns is applied.

Returns ViewCommand — The command.