#include <command_palette.h>
Public Member Functions | |
| void | AddCommand (const std::string &name, const std::string &category, const std::string &description, const std::string &shortcut, std::function< void()> callback) |
| void | RecordUsage (const std::string &name) |
| std::vector< CommandEntry > | SearchCommands (const std::string &query) |
| std::vector< CommandEntry > | GetRecentCommands (int limit=10) |
| std::vector< CommandEntry > | GetFrequentCommands (int limit=10) |
| std::vector< CommandEntry > | GetAllCommands () const |
| Get all registered commands. | |
| size_t | GetCommandCount () const |
| Get command count. | |
| void | Clear () |
| Clear all commands (and forget every registered provider). | |
| void | RegisterProvider (std::unique_ptr< CommandProvider > provider) |
| void | UnregisterProvider (const std::string &provider_id) |
| void | RefreshProvider (const std::string &provider_id) |
| void | RefreshProviders () |
| Remove-and-re-run every registered provider. | |
| void | RemoveProviderCommands (const std::string &provider_id) |
| void | RegisterPanelCommands (WorkspaceWindowManager *window_manager, size_t session_id) |
| Register all window toggle commands from WorkspaceWindowManager. | |
| void | RegisterEditorCommands (std::function< void(const std::string &)> switch_callback) |
| Register all editor switch commands. | |
| void | RegisterLayoutCommands (std::function< void(const std::string &)> apply_callback) |
| Register layout preset commands. | |
| void | RegisterRecentFilesCommands (std::function< void(const std::string &)> open_callback) |
| Register commands to open recent files. | |
| void | RegisterDungeonRoomCommands (size_t session_id) |
| Register dungeon room navigation commands. | |
| void | RegisterWorkflowCommands (WorkspaceWindowManager *window_manager, size_t session_id) |
| Register hack workflow commands from workflow-aware panels/actions. | |
| void | RegisterWelcomeCommands (const RecentProjectsModel *model, const std::vector< std::string > &template_names, std::function< void(const std::string &)> remove_callback, std::function< void(const std::string &)> toggle_pin_callback, std::function< void()> undo_remove_callback, std::function< void()> clear_recents_callback, std::function< void(const std::string &)> create_from_template_callback, std::function< void()> dismiss_welcome_callback, std::function< void()> show_welcome_callback) |
| Expose welcome-screen actions through the command palette. | |
| void | SaveHistory (const std::string &filepath) |
| Save command usage history to disk. | |
| void | LoadHistory (const std::string &filepath) |
| Load command usage history from disk. | |
Static Public Member Functions | |
| static int | FuzzyScore (const std::string &text, const std::string &query) |
Private Attributes | |
| std::unordered_map< std::string, CommandEntry > | commands_ |
| std::vector< std::unique_ptr< CommandProvider > > | providers_ |
| std::string | current_provider_id_ |
Definition at line 63 of file command_palette.h.
| void yaze::editor::CommandPalette::AddCommand | ( | const std::string & | name, |
| const std::string & | category, | ||
| const std::string & | description, | ||
| const std::string & | shortcut, | ||
| std::function< void()> | callback ) |
Definition at line 23 of file command_palette.cc.
References yaze::editor::CommandEntry::callback, yaze::editor::CommandEntry::category, commands_, current_provider_id_, yaze::editor::CommandEntry::description, yaze::editor::CommandEntry::name, yaze::editor::CommandEntry::provider_id, and yaze::editor::CommandEntry::shortcut.
Referenced by yaze::editor::UICoordinator::InitializeCommandPalette(), yaze::editor::SidebarCommandsProvider::Provide(), RegisterDungeonRoomCommands(), RegisterEditorCommands(), RegisterLayoutCommands(), RegisterPanelCommands(), RegisterRecentFilesCommands(), RegisterWelcomeCommands(), and RegisterWorkflowCommands().
| void yaze::editor::CommandPalette::RecordUsage | ( | const std::string & | name | ) |
Definition at line 119 of file command_palette.cc.
References commands_.
Referenced by yaze::editor::UICoordinator::DrawCommandPalette(), and yaze::editor::CommandPaletteWidget::ExecuteCommand().
| std::vector< CommandEntry > yaze::editor::CommandPalette::SearchCommands | ( | const std::string & | query | ) |
Definition at line 174 of file command_palette.cc.
References commands_, and FuzzyScore().
Referenced by yaze::editor::CommandPaletteWidget::Draw().

| std::vector< CommandEntry > yaze::editor::CommandPalette::GetRecentCommands | ( | int | limit = 10 | ) |
Definition at line 215 of file command_palette.cc.
References commands_.
Referenced by yaze::editor::CommandPaletteWidget::Draw(), and yaze::editor::UICoordinator::DrawCommandPalette().
| std::vector< CommandEntry > yaze::editor::CommandPalette::GetFrequentCommands | ( | int | limit = 10 | ) |
Definition at line 236 of file command_palette.cc.
References commands_.
Referenced by yaze::editor::CommandPaletteWidget::Draw(), and yaze::editor::UICoordinator::DrawCommandPalette().
| std::vector< CommandEntry > yaze::editor::CommandPalette::GetAllCommands | ( | ) | const |
Get all registered commands.
Definition at line 319 of file command_palette.cc.
References commands_.
Referenced by yaze::editor::CommandPaletteWidget::Draw(), and yaze::editor::UICoordinator::DrawCommandPalette().
|
inline |
| void yaze::editor::CommandPalette::Clear | ( | ) |
Clear all commands (and forget every registered provider).
Definition at line 38 of file command_palette.cc.
References commands_, current_provider_id_, and providers_.
Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().
| void yaze::editor::CommandPalette::RegisterProvider | ( | std::unique_ptr< CommandProvider > | provider | ) |
Register provider and run it once. Entries added during Provide() are attributed to the provider's id. The provider stays registered so it can be re-run via RefreshProvider / RefreshProviders. A duplicate id replaces the prior registration (the old provider's commands are dropped first).
Definition at line 44 of file command_palette.cc.
References current_provider_id_, LOG_WARN, yaze::editor::CommandProvider::Provide(), providers_, and RemoveProviderCommands().
Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

| void yaze::editor::CommandPalette::UnregisterProvider | ( | const std::string & | provider_id | ) |
Remove every command attributed to provider_id and drop the provider. No-op if the id is unknown.
Definition at line 72 of file command_palette.cc.
References providers_, and RemoveProviderCommands().

| void yaze::editor::CommandPalette::RefreshProvider | ( | const std::string & | provider_id | ) |
Remove-and-re-run a single provider. Useful after its underlying data changed (e.g., recent-files list). No-op if the id is unknown.
Definition at line 82 of file command_palette.cc.
References current_provider_id_, providers_, and RemoveProviderCommands().
Referenced by RefreshProviders().

| void yaze::editor::CommandPalette::RefreshProviders | ( | ) |
Remove-and-re-run every registered provider.
Definition at line 94 of file command_palette.cc.
References providers_, and RefreshProvider().

| void yaze::editor::CommandPalette::RemoveProviderCommands | ( | const std::string & | provider_id | ) |
Remove every command with the given provider attribution. Leaves the provider itself registered so RefreshProvider can repopulate later.
Definition at line 107 of file command_palette.cc.
References commands_.
Referenced by RefreshProvider(), RegisterProvider(), and UnregisterProvider().
| void yaze::editor::CommandPalette::RegisterPanelCommands | ( | WorkspaceWindowManager * | window_manager, |
| size_t | session_id ) |
Register all window toggle commands from WorkspaceWindowManager.
| window_manager | The panel manager to query for panels |
| session_id | Current session ID for panel prefixing |
Definition at line 328 of file command_palette.cc.
References AddCommand(), yaze::editor::WorkspaceWindowManager::CloseWindow(), yaze::editor::WorkspaceWindowManager::GetWindowDescriptor(), yaze::editor::WorkspaceWindowManager::GetWindowsInSession(), yaze::editor::WorkspaceWindowManager::IsWindowPinned(), yaze::editor::CommandCategory::kPanel, yaze::editor::WorkspaceWindowManager::SetWindowPinned(), and yaze::editor::WorkspaceWindowManager::ToggleWindow().
Referenced by yaze::editor::PanelCommandsProvider::Provide().
| void yaze::editor::CommandPalette::RegisterEditorCommands | ( | std::function< void(const std::string &)> | switch_callback | ) |
Register all editor switch commands.
| switch_callback | Callback to switch to an editor category |
Definition at line 392 of file command_palette.cc.
References AddCommand(), yaze::editor::EditorRegistry::GetAllEditorCategories(), and yaze::editor::CommandCategory::kEditor.
Referenced by yaze::editor::EditorCommandsProvider::Provide().

| void yaze::editor::CommandPalette::RegisterLayoutCommands | ( | std::function< void(const std::string &)> | apply_callback | ) |
Register layout preset commands.
| apply_callback | Callback to apply a layout preset by name |
Definition at line 407 of file command_palette.cc.
References AddCommand(), and yaze::editor::CommandCategory::kLayout.

| void yaze::editor::CommandPalette::RegisterRecentFilesCommands | ( | std::function< void(const std::string &)> | open_callback | ) |
Register commands to open recent files.
| open_callback | Callback to open a file by path |
Creates "Open Recent: <filename>" commands for each file in RecentFilesManager. Files are checked for existence before registration.
Definition at line 475 of file command_palette.cc.
References AddCommand(), yaze::project::RecentFilesManager::GetInstance(), yaze::project::RecentFilesManager::GetRecentFiles(), and yaze::editor::CommandCategory::kFile.
Referenced by yaze::editor::RecentFilesCommandsProvider::Provide().

| void yaze::editor::CommandPalette::RegisterDungeonRoomCommands | ( | size_t | session_id | ) |
Register dungeon room navigation commands.
Adds one command per room ID (0x000-0x127) using the ResourceLabelProvider label (when available). Commands publish JumpToRoomRequestEvent.
Definition at line 498 of file command_palette.cc.
References AddCommand(), yaze::editor::JumpToRoomRequestEvent::Create(), yaze::editor::ContentRegistry::Context::event_bus(), yaze::zelda3::GetRoomLabel(), and yaze::editor::CommandCategory::kNavigation.
Referenced by yaze::editor::DungeonRoomCommandsProvider::Provide().

| void yaze::editor::CommandPalette::RegisterWorkflowCommands | ( | WorkspaceWindowManager * | window_manager, |
| size_t | session_id ) |
Register hack workflow commands from workflow-aware panels/actions.
Definition at line 519 of file command_palette.cc.
References AddCommand(), yaze::editor::ContentRegistry::WorkflowActions::GetAll(), yaze::editor::WorkspaceWindowManager::GetAllCategories(), yaze::editor::WorkspaceWindowManager::GetWindowsInCategory(), and yaze::editor::CommandCategory::kWorkflow.
Referenced by yaze::editor::WorkflowCommandsProvider::Provide().

| void yaze::editor::CommandPalette::RegisterWelcomeCommands | ( | const RecentProjectsModel * | model, |
| const std::vector< std::string > & | template_names, | ||
| std::function< void(const std::string &)> | remove_callback, | ||
| std::function< void(const std::string &)> | toggle_pin_callback, | ||
| std::function< void()> | undo_remove_callback, | ||
| std::function< void()> | clear_recents_callback, | ||
| std::function< void(const std::string &)> | create_from_template_callback, | ||
| std::function< void()> | dismiss_welcome_callback, | ||
| std::function< void()> | show_welcome_callback ) |
Expose welcome-screen actions through the command palette.
Registers commands that surface recent-project mutations (remove, pin, undo, clear), template-based project creation, and welcome-screen visibility toggles. This lets power users drive the welcome screen entirely from the palette without opening it.
The RecentProjectsModel pointer may be null; in that case the per-entry remove/pin commands are skipped but the global commands still register.
| model | Source of recent-project entries (not owned, may be null). |
| template_names | Display names of project templates to register "Create from Template: <name>" commands for. If empty, the template commands are skipped. |
| remove_callback | Invoked with the filepath to remove from recents. |
| toggle_pin_callback | Invoked with the filepath to flip pin state. |
| undo_remove_callback | Invoked to restore the last-removed entry. |
| clear_recents_callback | Invoked to clear all recents. |
| create_from_template_callback | Invoked with the template display name to kick off the "new project" flow for that template. |
| dismiss_welcome_callback | Invoked to hide the welcome screen. |
| show_welcome_callback | Invoked to bring the welcome screen back. |
Definition at line 564 of file command_palette.cc.
References AddCommand(), yaze::editor::RecentProjectsModel::entries(), yaze::editor::CommandCategory::kFile, and yaze::editor::CommandCategory::kView.
Referenced by yaze::editor::WelcomeCommandsProvider::Provide().

| void yaze::editor::CommandPalette::SaveHistory | ( | const std::string & | filepath | ) |
Save command usage history to disk.
| filepath | Path to save JSON history file |
Definition at line 257 of file command_palette.cc.
References commands_, yaze::Json::dump(), LOG_ERROR, LOG_INFO, and yaze::Json::object().
Referenced by yaze::editor::UICoordinator::DrawCommandPalette().

| void yaze::editor::CommandPalette::LoadHistory | ( | const std::string & | filepath | ) |
Load command usage history from disk.
| filepath | Path to load JSON history file from |
Definition at line 283 of file command_palette.cc.
References commands_, yaze::Json::contains(), yaze::Json::is_object(), yaze::Json::items(), LOG_ERROR, LOG_INFO, and yaze::Json::parse().
Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

|
static |
Definition at line 130 of file command_palette.cc.
Referenced by yaze::editor::UICoordinator::DrawPanelFinder(), and SearchCommands().
|
private |
Definition at line 218 of file command_palette.h.
Referenced by AddCommand(), Clear(), GetAllCommands(), GetCommandCount(), GetFrequentCommands(), GetRecentCommands(), LoadHistory(), RecordUsage(), RemoveProviderCommands(), SaveHistory(), and SearchCommands().
|
private |
Definition at line 219 of file command_palette.h.
Referenced by Clear(), RefreshProvider(), RefreshProviders(), RegisterProvider(), and UnregisterProvider().
|
private |
Set while a provider's Provide() call is on the stack; stamped into every CommandEntry added during that call. Empty outside Provide().
Definition at line 222 of file command_palette.h.
Referenced by AddCommand(), Clear(), RefreshProvider(), and RegisterProvider().