yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
command_palette.h
Go to the documentation of this file.
1#ifndef YAZE_APP_EDITOR_SYSTEM_COMMAND_PALETTE_H_
2#define YAZE_APP_EDITOR_SYSTEM_COMMAND_PALETTE_H_
3
4#include <string>
5#include <vector>
6#include <unordered_map>
7#include <functional>
8
9namespace yaze {
10namespace editor {
11
13 std::string name;
14 std::string category;
15 std::string description;
16 std::string shortcut;
17 std::function<void()> callback;
18 int usage_count = 0;
19 int64_t last_used_ms = 0;
20};
21
23 public:
24 void AddCommand(const std::string& name, const std::string& category,
25 const std::string& description, const std::string& shortcut,
26 std::function<void()> callback);
27
28 void RecordUsage(const std::string& name);
29
30 std::vector<CommandEntry> SearchCommands(const std::string& query);
31
32 std::vector<CommandEntry> GetRecentCommands(int limit = 10);
33
34 std::vector<CommandEntry> GetFrequentCommands(int limit = 10);
35
36 void SaveHistory(const std::string& filepath);
37 void LoadHistory(const std::string& filepath);
38
39 private:
40 std::unordered_map<std::string, CommandEntry> commands_;
41
42 int FuzzyScore(const std::string& text, const std::string& query);
43};
44
45} // namespace editor
46} // namespace yaze
47
48#endif // YAZE_APP_EDITOR_SYSTEM_COMMAND_PALETTE_H_
std::vector< CommandEntry > SearchCommands(const std::string &query)
void SaveHistory(const std::string &filepath)
void AddCommand(const std::string &name, const std::string &category, const std::string &description, const std::string &shortcut, std::function< void()> callback)
void LoadHistory(const std::string &filepath)
void RecordUsage(const std::string &name)
std::unordered_map< std::string, CommandEntry > commands_
std::vector< CommandEntry > GetRecentCommands(int limit=10)
std::vector< CommandEntry > GetFrequentCommands(int limit=10)
int FuzzyScore(const std::string &text, const std::string &query)
Main namespace for the application.
std::function< void()> callback