MCPcopy Create free account
hub / github.com/Bush2021/chrome_plus / LoadKeyMappings

Method LoadKeyMappings

src/config.cc:64–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62}
63
64void Config::LoadKeyMappings() {
65 std::vector<wchar_t> buffer(4096);
66 const DWORD chars_read = ::GetPrivateProfileSectionW(
67 L"keymapping", buffer.data(), static_cast<DWORD>(buffer.size()),
68 GetIniPath().c_str());
69
70 if (chars_read == 0) {
71 return;
72 }
73
74 const wchar_t* current = buffer.data();
75 while (*current != L'\0') {
76 const std::wstring_view line(current);
77 current += line.length() + 1;
78
79 const auto eq_pos = line.find(L'=');
80 if (eq_pos == std::wstring_view::npos || eq_pos == 0) {
81 continue;
82 }
83
84 std::wstring_view key = line.substr(0, eq_pos);
85 std::wstring_view value = line.substr(eq_pos + 1);
86
87 while (!key.empty() && (key.back() == L' ' || key.back() == L'\t')) {
88 key.remove_suffix(1);
89 }
90 while (!value.empty() &&
91 (value.front() == L' ' || value.front() == L'\t')) {
92 value.remove_prefix(1);
93 }
94
95 if (!key.empty() && !value.empty()) {
96 key_mappings_.emplace_back(std::wstring(key), std::wstring(value));
97 }
98 }
99}
100
101std::optional<std::wstring> Config::LoadDirPath(const std::wstring& dir_type) {
102 std::wstring path = CanonicalizePath(GetAppDir() + L"\\..\\" + dir_type);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected