#include <command_palette.h>
Classes | |
| struct | UsageStats |
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) |
| bool | RecordUsage (const std::string &name) |
| std::vector< CommandEntry > | SearchCommands (const std::string &query) |
| std::vector< CommandMatch > | Search (const std::string &query, int64_t now_ms) const |
| std::vector< CommandMatch > | Search (const std::string &query) const |
| std::vector< CommandEntry > | GetRecentCommands (int limit=10) |
| std::vector< CommandEntry > | GetFrequentCommands (int limit=10) |
| std::vector< CommandEntry > | GetAllCommands () const |
| Get all registered commands (raw, not deduplicated) | |
| std::vector< CommandEntry > | GetVisibleCommands () const |
| size_t | GetCommandCount () const |
| Get command count. | |
| void | Clear () |
| Clear all commands (and forget every registered provider). Usage history is kept so refreshing providers does not reset frecency. | |
| 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 | RegisterOverworldMapCommands (size_t session_id) |
| Register overworld map navigation commands (0x00-0x9F). | |
| void | RegisterDungeonRoomCommands (size_t session_id) |
| Register dungeon room navigation commands. | |
| void | RegisterDrawerCommands (std::function< void(int drawer_type)> toggle_callback, std::function< void()> cycle_next={}, std::function< void()> cycle_prev={}) |
| Register right-drawer toggle commands from GetDrawerCatalog(). | |
| 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. | |
| std::string | CanonicalCommandName (const std::string &name) const |
| uint64_t | generation () const |
Static Public Member Functions | |
| static int | FuzzyScore (const std::string &text, const std::string &query) |
| Legacy name for ScoreText (kept for the Window Finder). | |
| static int | ScoreText (std::string_view text, std::string_view query) |
| static int | ScoreEntry (const CommandEntry &entry, std::string_view query, int64_t now_ms) |
| static std::string | NormalizeCommandName (std::string_view name) |
| static bool | IsInternalCommandId (std::string_view name) |
| static int64_t | NowMs () |
Private Attributes | |
| uint64_t | generation_ = 0 |
| std::unordered_map< std::string, CommandEntry > | commands_ |
| std::unordered_map< std::string, UsageStats > | usage_ |
| Usage keyed by command name; survives Clear() and provider refreshes. | |
| std::vector< std::unique_ptr< CommandProvider > > | providers_ |
| std::string | current_provider_id_ |
Definition at line 76 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 182 of file command_palette.cc.
References yaze::editor::CommandEntry::callback, yaze::editor::CommandEntry::category, commands_, current_provider_id_, yaze::editor::CommandEntry::description, generation_, yaze::editor::CommandEntry::last_used_ms, yaze::editor::CommandEntry::name, yaze::editor::CommandEntry::provider_id, yaze::editor::CommandEntry::shortcut, usage_, and yaze::editor::CommandEntry::usage_count.
Referenced by yaze::editor::ShortcutCommandsProvider::Provide(), yaze::editor::SidebarCommandsProvider::Provide(), and RegisterPanelCommands().
| bool yaze::editor::CommandPalette::RecordUsage | ( | const std::string & | name | ) |
Record one execution of name. Only names the palette knows (after dedupe, see CanonicalCommandName) are counted; returns false otherwise. Usage survives Clear()/provider refreshes.
Definition at line 285 of file command_palette.cc.
References CanonicalCommandName(), commands_, generation_, NormalizeCommandName(), NowMs(), and usage_.
Referenced by yaze::editor::UICoordinator::ExecutePaletteCommand().

| std::vector< CommandEntry > yaze::editor::CommandPalette::SearchCommands | ( | const std::string & | query | ) |
Ranked, deduplicated search. An empty query lists every visible command (recently used first, then by name). Recency/frequency only boosts entries that already match the query.
Definition at line 519 of file command_palette.cc.
References Search().

| std::vector< CommandMatch > yaze::editor::CommandPalette::Search | ( | const std::string & | query, |
| int64_t | now_ms ) const |
Definition at line 491 of file command_palette.cc.
References GetVisibleCommands(), and ScoreEntry().
Referenced by yaze::editor::UICoordinator::DrawCommandPalette(), Search(), and SearchCommands().

| std::vector< CommandMatch > yaze::editor::CommandPalette::Search | ( | const std::string & | query | ) | const |
Definition at line 514 of file command_palette.cc.
References NowMs(), and Search().

| std::vector< CommandEntry > yaze::editor::CommandPalette::GetRecentCommands | ( | int | limit = 10 | ) |
Definition at line 528 of file command_palette.cc.
References GetVisibleCommands().
Referenced by yaze::editor::UICoordinator::DrawCommandPalette().

| std::vector< CommandEntry > yaze::editor::CommandPalette::GetFrequentCommands | ( | int | limit = 10 | ) |
Definition at line 543 of file command_palette.cc.
References GetVisibleCommands().
Referenced by yaze::editor::UICoordinator::DrawCommandPalette().

| std::vector< CommandEntry > yaze::editor::CommandPalette::GetAllCommands | ( | ) | const |
Get all registered commands (raw, not deduplicated)
Definition at line 626 of file command_palette.cc.
References commands_.
| std::vector< CommandEntry > yaze::editor::CommandPalette::GetVisibleCommands | ( | ) | const |
Commands after hiding duplicates (see NormalizeCommandName). Each group is represented by one entry that inherits the first non-empty shortcut and the group's best usage stats. Sorted by name.
Definition at line 395 of file command_palette.cc.
References yaze::editor::CommandEntry::callback, commands_, IsInternalCommandId(), yaze::editor::CommandEntry::last_used_ms, NormalizeCommandName(), yaze::editor::CommandEntry::shortcut, and yaze::editor::CommandEntry::usage_count.
Referenced by CanonicalCommandName(), GetFrequentCommands(), GetRecentCommands(), and Search().

|
inline |
| void yaze::editor::CommandPalette::Clear | ( | ) |
Clear all commands (and forget every registered provider). Usage history is kept so refreshing providers does not reset frecency.
Definition at line 202 of file command_palette.cc.
References commands_, current_provider_id_, generation_, 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 209 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 237 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 247 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 259 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 272 of file command_palette.cc.
References commands_, and generation_.
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 635 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 747 of file command_palette.cc.
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 762 of file command_palette.cc.
Referenced by yaze::editor::LayoutCommandsProvider::Provide().
| 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 852 of file command_palette.cc.
References yaze::project::RecentFilesManager::GetInstance(), and yaze::project::RecentFilesManager::GetRecentFiles().
Referenced by yaze::editor::RecentFilesCommandsProvider::Provide().

| void yaze::editor::CommandPalette::RegisterOverworldMapCommands | ( | size_t | session_id | ) |
Register overworld map navigation commands (0x00-0x9F).
Commands publish JumpToMapRequestEvent; names carry the resource label when one exists.
Definition at line 875 of file command_palette.cc.
References yaze::zelda3::GetOverworldMapLabel(), and yaze::zelda3::kNumOverworldMaps.
Referenced by yaze::editor::OverworldMapCommandsProvider::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 893 of file command_palette.cc.
References yaze::zelda3::GetRoomLabel().
Referenced by yaze::editor::DungeonRoomCommandsProvider::Provide().

| void yaze::editor::CommandPalette::RegisterDrawerCommands | ( | std::function< void(int drawer_type)> | toggle_callback, |
| std::function< void()> | cycle_next = {}, | ||
| std::function< void()> | cycle_prev = {} ) |
Register right-drawer toggle commands from GetDrawerCatalog().
Names use a "drawer: " prefix so palette search (drawer:) groups them.
| toggle_callback | Receives RightDrawerManager::DrawerType as int. |
Definition at line 717 of file command_palette.cc.
References yaze::editor::GetDrawerCatalog().
Referenced by yaze::editor::DrawerCommandsProvider::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 914 of file command_palette.cc.
References yaze::editor::WorkspaceWindowManager::GetAllCategories(), and yaze::editor::WorkspaceWindowManager::GetWindowsInCategory().
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 959 of file command_palette.cc.
References yaze::editor::RecentProjectsModel::entries().
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 558 of file command_palette.cc.
References yaze::Json::dump(), LOG_DEBUG, LOG_ERROR, yaze::Json::object(), and usage_.
Referenced by yaze::editor::UICoordinator::SaveCommandPaletteHistory().

| 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 584 of file command_palette.cc.
References commands_, yaze::Json::contains(), yaze::editor::CommandPalette::UsageStats::count, generation_, yaze::Json::is_object(), yaze::Json::items(), yaze::editor::CommandPalette::UsageStats::last_used_ms, LOG_ERROR, LOG_INFO, yaze::Json::parse(), and usage_.
Referenced by yaze::editor::UICoordinator::InitializeCommandPalette().

|
static |
Legacy name for ScoreText (kept for the Window Finder).
Definition at line 309 of file command_palette.cc.
References ScoreText().
Referenced by yaze::editor::UICoordinator::DrawPanelFinder().

|
static |
Unified scorer, case-insensitive. 0 = no match. Tiers (high to low): exact > prefix > substring at a word start > substring elsewhere > in-order subsequence. Subsequence matches earn a word-start bonus that outweighs the consecutive-character bonus, and always stay below every substring tier. Queries with spaces also match when every token matches.
Definition at line 314 of file command_palette.cc.
Referenced by FuzzyScore(), and ScoreEntry().
|
static |
Score one entry: name first, then category/description at reduced weight, then a frecency boost that is only applied when the text matched. Returns 0 when nothing matched.
Definition at line 338 of file command_palette.cc.
References yaze::editor::CommandEntry::category, yaze::editor::CommandEntry::description, yaze::editor::CommandEntry::last_used_ms, yaze::editor::CommandEntry::name, ScoreText(), and yaze::editor::CommandEntry::usage_count.
Referenced by Search().

|
static |
Lowercase, strip punctuation and "(Alt)" suffixes, collapse spaces, and treat the word "panel(s)" as "window(s)". "Switch to: Overworld Editor" and "Switch to Overworld Editor" share a key, as do "Panel Browser" and "Window Browser", so only one of each is listed (Window names win).
Definition at line 349 of file command_palette.cc.
Referenced by CanonicalCommandName(), GetVisibleCommands(), and RecordUsage().
|
static |
True for dotted/underscored ids such as "switch.3" or "graphics.tool.pencil" that are keybinding ids, not user-facing names.
Definition at line 383 of file command_palette.cc.
Referenced by GetVisibleCommands(), and yaze::editor::PaletteNameForShortcut().
| std::string yaze::editor::CommandPalette::CanonicalCommandName | ( | const std::string & | name | ) | const |
Name of the entry that represents name after dedupe, or empty when the palette has no such command.
Definition at line 479 of file command_palette.cc.
References GetVisibleCommands(), and NormalizeCommandName().
Referenced by RecordUsage().

|
static |
Definition at line 176 of file command_palette.cc.
Referenced by RecordUsage(), and Search().
|
inline |
Bumped on every mutation (commands, providers, usage). Lets callers cache Search() results per query across frames.
Definition at line 296 of file command_palette.h.
References generation_.
Referenced by yaze::editor::UICoordinator::DrawCommandPalette().
|
private |
Definition at line 299 of file command_palette.h.
Referenced by AddCommand(), Clear(), generation(), LoadHistory(), RecordUsage(), and RemoveProviderCommands().
|
private |
Definition at line 305 of file command_palette.h.
Referenced by AddCommand(), Clear(), GetAllCommands(), GetCommandCount(), GetVisibleCommands(), LoadHistory(), RecordUsage(), and RemoveProviderCommands().
|
private |
Usage keyed by command name; survives Clear() and provider refreshes.
Definition at line 307 of file command_palette.h.
Referenced by AddCommand(), LoadHistory(), RecordUsage(), and SaveHistory().
|
private |
Definition at line 308 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 311 of file command_palette.h.
Referenced by AddCommand(), Clear(), RefreshProvider(), and RegisterProvider().