CommanderCommand
ConsoleMonster.Apps.Commander
One Commander command as data: a stable key, a label, its keys (the first is primary, the rest are alternatives for terminals that swallow F-keys), an optional key-bar slot, when it's available and what it does. The palette, key bar, help and key routing all come from the same CommanderCommands.
Inheritance
- object
- CommanderCommand
Usage
Explore 6 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 5
- Method CommanderCommands.Find
- Method CommanderCommands.GetEnumerator
- Method CommanderCommands.Match
- Property CommanderCommands.Item
- Property CommanderKeyBarItem.Command
Accepted by parameters 1
- Constructor CommanderCommands.CommanderCommands
Constructors
public CommanderCommand(string key, string label, Action<CommanderContext> execute, params KeyChord[] keys) #Creates a command.
Parameters
- key string
- The stable key, such as copy.
- label string
- What it does, for the palette and help.
- execute System.Action<ConsoleMonster.Apps.Commander.CommanderContext>
- The action, called on the app thread when the command is available.
- keys ConsoleMonster.Input.KeyChord[]
- Its keys, primary first; none for palette-only commands.
Methods
public bool IsAvailable(CommanderContext context) #Whether the command can run now; unavailable commands do nothing and show dimmed.
Parameters
- context ConsoleMonster.Apps.Commander.CommanderContext
- The context.
Returns
bool True when available.public bool Matches(InputEvent input) #Whether a key event is one of this command's keys.
Parameters
- input ConsoleMonster.Input.InputEvent
- The event.
Returns
bool True on a match.public KeyBinding ToKeyBinding(CommanderContext context) #The command as a key binding, for the app host's routing, footer and key map.
Parameters
- context ConsoleMonster.Apps.Commander.CommanderContext
- The context its action runs in.
public override string ToString() #Returns a string that represents the current object.
Returns
string A string that represents the current object.public bool TryExecute(CommanderContext context) #Runs the command when it's available.
Parameters
- context ConsoleMonster.Apps.Commander.CommanderContext
- The context.
Returns
bool Whether it ran.Inherited Methods
Properties
public KeyChord? Gesture { get; } #The primary key, or null for a palette-only command.
public int FunctionKey { get; set; } #The key-bar slot from 1 to 10, or 0 when it has none.
public string? BarLabel { get; set; } #The short key-bar label, such as Mkdir; the label when null.
public bool RequiresHost { get; set; } #Whether the command needs ICommanderHost.Supports to be true.
public Func<CommanderContext, bool>? Available { get; set; } #When the command can run; always when null.