Central command dispatcher.
More...
#include <command_registry.hpp>
Central command dispatcher.
One per application (or per window, if you want per-window scopes). Owns the ShortcutMap and a chain of registered CommandHandler pointers.
◆ CommandRegistry() [1/2]
| pulp::view::CommandRegistry::CommandRegistry |
( |
| ) |
|
|
default |
◆ ~CommandRegistry()
| pulp::view::CommandRegistry::~CommandRegistry |
( |
| ) |
|
|
default |
◆ CommandRegistry() [2/2]
| pulp::view::CommandRegistry::CommandRegistry |
( |
const CommandRegistry & | | ) |
|
|
delete |
◆ add_handler()
| void pulp::view::CommandRegistry::add_handler |
( |
CommandHandler * | handler | ) |
|
Add a handler to the front of the dispatch chain (highest priority).
Caller retains ownership; must call remove_handler before the handler is destroyed.
◆ command_info()
Look up a command by id. Returns nullopt if unknown.
◆ commands()
| const std::vector< CommandInfo > & pulp::view::CommandRegistry::commands |
( |
| ) |
const |
|
inline |
All registered commands, in registration order.
◆ dispatch()
| bool pulp::view::CommandRegistry::dispatch |
( |
CommandID | id | ) |
|
Dispatch a command id through the handler chain.
Returns true if some handler claimed it. Commands marked enabled=false are not dispatched and the call returns false.
◆ dispatch_key_event()
| bool pulp::view::CommandRegistry::dispatch_key_event |
( |
const KeyEvent & | event | ) |
|
Dispatch a key event: look up the chord in the ShortcutMap, then dispatch the resulting command (if any).
Returns true iff a command was found AND a handler claimed it.
◆ handler_count()
| std::size_t pulp::view::CommandRegistry::handler_count |
( |
| ) |
const |
|
inline |
Number of handlers currently in the chain.
◆ operator=()
◆ register_command()
| void pulp::view::CommandRegistry::register_command |
( |
const CommandInfo & | info | ) |
|
Register a command.
If the info's default_key is non-unknown, the registry also binds the default chord in the ShortcutMap (unless that chord is already bound — user-loaded rebindings take priority, which is why apps should load the shortcut map from disk BEFORE calling register_command).
◆ remove_handler()
| void pulp::view::CommandRegistry::remove_handler |
( |
CommandHandler * | handler | ) |
|
Remove a handler from the chain.
Safe to call with an unknown pointer (no-op).
◆ set_enabled()
| void pulp::view::CommandRegistry::set_enabled |
( |
CommandID | id, |
|
|
bool | enabled ) |
Mutate a command's enabled flag (e.g.
greys out "Undo" when the stack is empty). Does not change shortcut bindings.
◆ shortcuts() [1/2]
| ShortcutMap & pulp::view::CommandRegistry::shortcuts |
( |
| ) |
|
|
inline |
◆ shortcuts() [2/2]
| const ShortcutMap & pulp::view::CommandRegistry::shortcuts |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: