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
9
namespace
yaze
{
10
namespace
editor {
11
12
struct
CommandEntry
{
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
22
class
CommandPalette
{
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_
yaze::editor::CommandPalette
Definition
command_palette.h:22
yaze::editor::CommandPalette::SearchCommands
std::vector< CommandEntry > SearchCommands(const std::string &query)
Definition
command_palette.cc:68
yaze::editor::CommandPalette::SaveHistory
void SaveHistory(const std::string &filepath)
Definition
command_palette.cc:149
yaze::editor::CommandPalette::AddCommand
void AddCommand(const std::string &name, const std::string &category, const std::string &description, const std::string &shortcut, std::function< void()> callback)
Definition
command_palette.cc:10
yaze::editor::CommandPalette::LoadHistory
void LoadHistory(const std::string &filepath)
Definition
command_palette.cc:153
yaze::editor::CommandPalette::RecordUsage
void RecordUsage(const std::string &name)
Definition
command_palette.cc:22
yaze::editor::CommandPalette::commands_
std::unordered_map< std::string, CommandEntry > commands_
Definition
command_palette.h:40
yaze::editor::CommandPalette::GetRecentCommands
std::vector< CommandEntry > GetRecentCommands(int limit=10)
Definition
command_palette.cc:107
yaze::editor::CommandPalette::GetFrequentCommands
std::vector< CommandEntry > GetFrequentCommands(int limit=10)
Definition
command_palette.cc:128
yaze::editor::CommandPalette::FuzzyScore
int FuzzyScore(const std::string &text, const std::string &query)
Definition
command_palette.cc:32
yaze
Main namespace for the application.
Definition
asar_wrapper.cc:14
yaze::editor::CommandEntry
Definition
command_palette.h:12
yaze::editor::CommandEntry::name
std::string name
Definition
command_palette.h:13
yaze::editor::CommandEntry::last_used_ms
int64_t last_used_ms
Definition
command_palette.h:19
yaze::editor::CommandEntry::category
std::string category
Definition
command_palette.h:14
yaze::editor::CommandEntry::description
std::string description
Definition
command_palette.h:15
yaze::editor::CommandEntry::callback
std::function< void()> callback
Definition
command_palette.h:17
yaze::editor::CommandEntry::shortcut
std::string shortcut
Definition
command_palette.h:16
yaze::editor::CommandEntry::usage_count
int usage_count
Definition
command_palette.h:18
src
app
editor
system
command_palette.h
Generated by
1.9.8