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
| Member | Summary |
|---|---|
ViewCommand() |
Properties
| Member | Summary |
|---|---|
Binding | Key that runs the command. Checked before the screen's own key handling. |
IsEnabled | 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. |
Label | Name shown in the palette and the hints box; a delegate, so it can be translated. |
Run | What the command does. |
Methods
| Member | Summary |
|---|---|
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()
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
| Name | Type | Description |
|---|---|---|
binding | KeyBinding | Key that runs it. |
label | Func<TResult><string> | Name shown to the user. |
run | Action | What 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
| Name | Type | Description |
|---|---|---|
key | ConsoleKey | Key that runs it. |
label | Func<TResult><string> | Name shown to the user. |
run | Action | What to do. |
Returns ViewCommand — The command.
Navigating(ConsoleKey, Func<string>, Func<ViewRoute>)
public static ViewCommand Navigating(ConsoleKey key, Func<string> label, Func<ViewRoute> run);
A command on a plain key that navigates somewhere.
Parameters
| Name | Type | Description |
|---|---|---|
key | ConsoleKey | Key that runs it. |
label | Func<TResult><string> | Name shown to the user. |
run | Func<TResult><ViewRoute> | What to do; the route it returns is applied. |
Returns ViewCommand — The command.