MCPcopy Create free account
hub / github.com/DFHack/dfhack / listKeybinds

Method listKeybinds

library/modules/Hotkey.cpp:232–260  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232std::vector<std::string> HotkeyManager::listKeybinds(const KeySpec& spec) {
233 std::lock_guard<std::mutex> l(lock);
234 if (!bindings.contains(spec.sym))
235 return {};
236
237 std::vector<std::string> out;
238
239 auto& binds = bindings[spec.sym];
240 for (const auto& bind : binds) {
241 if (bind.spec.modifiers != spec.modifiers)
242 continue;
243
244 // If no focus is required, it is always active
245 if (spec.focus.empty() || bind.spec.focus.empty()) {
246 out.push_back(bind.cmdline);
247 continue;
248 }
249
250 // If a focus is required, determine if search spec if the same or more specific
251 for (const auto& requested : spec.focus) {
252 for (const auto& to_match : bind.spec.focus) {
253 if (prefix_matches(to_match, requested))
254 out.push_back("@" + to_match + ":" + bind.cmdline);
255 }
256 }
257 }
258
259 return out;
260}
261
262std::vector<std::string> HotkeyManager::listKeybinds(std::string keyspec) {
263 std::optional<KeySpec> spec_opt = KeySpec::parse(std::move(keyspec));

Callers 1

keybindingMethod · 0.80

Calls 3

prefix_matchesFunction · 0.85
containsMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected