-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeymapStore.h
More file actions
83 lines (70 loc) · 2.16 KB
/
Copy pathKeymapStore.h
File metadata and controls
83 lines (70 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef SUMIRE_KEYMAP_STORE_H
#define SUMIRE_KEYMAP_STORE_H
#include <windows.h>
#include <filesystem>
#include <string>
#include <vector>
namespace SumireKeymap
{
struct Binding
{
std::wstring status;
std::wstring key;
std::wstring command;
bool enabled = true;
};
struct Profile
{
std::wstring id;
std::wstring name;
std::wstring sourceFormat = L"tsv";
std::wstring sourcePath;
bool isBuiltin = false;
std::wstring updatedAt;
std::vector<Binding> bindings;
};
struct Database
{
int version = 1;
std::wstring activeProfileId = L"ms-ime";
std::vector<Profile> profiles;
};
struct RuntimeKeymap
{
std::wstring activeProfileId;
std::vector<Binding> bindings;
bool loaded = false;
};
std::filesystem::path GetKeymapDirectory();
std::filesystem::path GetKeymapJsonPath();
std::filesystem::path GetBuiltinKeymapDirectory();
std::filesystem::path GetDefaultMsImeTsvPath();
std::filesystem::path GetDefaultAtokTsvPath();
bool EnsureInitialized(std::wstring* errorMessage = nullptr);
bool LoadDatabase(Database* database, std::wstring* errorMessage = nullptr);
bool SaveDatabase(const Database& database, std::wstring* errorMessage = nullptr);
bool LoadRuntimeKeymap(RuntimeKeymap* keymap, std::wstring* errorMessage = nullptr);
bool ImportTsvFileAsProfile(
const std::filesystem::path& path,
Database* database,
const std::wstring& profileId,
const std::wstring& profileName,
bool activate,
std::wstring* errorMessage = nullptr);
bool ExportProfileToTsv(
const Database& database,
const std::wstring& profileId,
const std::filesystem::path& path,
std::wstring* errorMessage = nullptr);
bool BackupDatabase(std::filesystem::path* backupPath = nullptr, std::wstring* errorMessage = nullptr);
std::wstring NormalizeKeyText(const std::wstring& key);
std::wstring NormalizeKeyStroke(WPARAM wParam, LPARAM lParam, bool* printableAscii = nullptr);
bool FindCommand(
const RuntimeKeymap& keymap,
const std::wstring& status,
const std::wstring& key,
bool printableAscii,
std::wstring* command);
bool IsSupportedCommand(const std::wstring& command);
}
#endif // SUMIRE_KEYMAP_STORE_H