CMiriCommandSystem
Global command registry and keybind manager
- Module
- Miri
- Header
#include "Miri/Commands/CMiriCommandSystem.h"- Namespace
Miri
Type aliases
| Alias | Description |
|---|---|
using FPersistedChordLookup = std::function<bool(const std::string& id, bool secondary, CInputChord& outChord)> | Answers "has the user rebound this command?" for an id at the moment it registers: true with the chord (an invalid chord means unbound), false to keep the default. The editor installs one over its keybindings file, so commands registered after startup get their remap too. |
Public functions
| Returns | Name | Description |
|---|---|---|
CMiriCommandSystem& | Get | |
void | RegisterCommand | Register a command (action bound separately via command lists). |
void | SetPersistedChordLookup | |
bool | SetAllowInTextInput | Marks a registered command as allowed to dispatch while a text input has focus (see CMiriCommand::AllowInTextInput). |
bool | RegisterCommand | Register command + parse chord + bind the callback in the global list. |
const CMiriCommand* | FindCommand | |
const CMiriCommand* | FindCommandByChord | The first of FindCommandsByChord, by command id. |
std::vector<const CMiriCommand*> | FindCommandsByChord | Every command bound to the chord (primary or secondary), sorted by id so resolution never depends on hash order. |
bool | RemapCommand | |
bool | RemapCommand | |
void | ResetToDefault | |
void | ResetAllToDefaults | |
void | PushCommandList | Most recently pushed list is consulted first |
void | PopCommandList | |
CMiriCommandList& | GetGlobalCommandList | Always-active fallback list, consulted after all pushed lists |
bool | HandleKey | Key-path entry point: executes the command bound to this chord. |
bool | ExecuteCommand | Execute by id: pushed lists (most specific first), then the global list |
std::string | GetChordDisplayString | "Ctrl+Shift+P" for the command's active chord; empty if unknown/unbound |
std::vector<const CMiriCommand*> | GetAllCommands |
Function details
Get
static CMiriCommandSystem& Get()RegisterCommand
void RegisterCommand(const CMiriCommand& command)Register a command (action bound separately via command lists). Registering an id again (a second Details tab, an editor built on first open) keeps a remap the user already made; a first registration takes the persisted chord from the lookup when one is installed.
SetPersistedChordLookup
void SetPersistedChordLookup(FPersistedChordLookup lookup)SetAllowInTextInput
bool SetAllowInTextInput(const CName& commandId, bool allow)Marks a registered command as allowed to dispatch while a text input has focus (see CMiriCommand::AllowInTextInput). False if unknown.
RegisterCommand
bool RegisterCommand(const std::string& id, const std::string& chord, std::function<void()> callback, const std::string& label = std::string())Register command + parse chord + bind the callback in the global list. Returns false (and registers nothing) if the chord string does not parse; an empty chord string registers a command with no keybind.
FindCommand
const CMiriCommand* FindCommand(const CName& id) constFindCommandByChord
const CMiriCommand* FindCommandByChord(const CInputChord& chord) constThe first of FindCommandsByChord, by command id.
FindCommandsByChord
std::vector<const CMiriCommand*> FindCommandsByChord(const CInputChord& chord) constEvery command bound to the chord (primary or secondary), sorted by id so resolution never depends on hash order.
RemapCommand
bool RemapCommand(const CName& commandId, const CInputChord& newChord)RemapCommand
bool RemapCommand(const CName& commandId, const CInputChord& newChord, bool secondary)ResetToDefault
void ResetToDefault(const CName& commandId)ResetAllToDefaults
void ResetAllToDefaults()PushCommandList
void PushCommandList(CMiriCommandList* list)Most recently pushed list is consulted first
PopCommandList
void PopCommandList()GetGlobalCommandList
CMiriCommandList& GetGlobalCommandList()Always-active fallback list, consulted after all pushed lists
HandleKey
bool HandleKey(EKey key, EModifierKey modifiers, bool focusedIsTextInput = false)Key-path entry point: executes the command bound to this chord. focusedIsTextInput restricts the candidates to AllowInTextInput ones.
ExecuteCommand
bool ExecuteCommand(const CName& commandId)Execute by id: pushed lists (most specific first), then the global list
GetChordDisplayString
std::string GetChordDisplayString(const CName& commandId) const"Ctrl+Shift+P" for the command's active chord; empty if unknown/unbound
GetAllCommands
std::vector<const CMiriCommand*> GetAllCommands() const