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

Method removeKeybind

library/modules/Hotkey.cpp:206–223  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204}
205
206bool HotkeyManager::removeKeybind(const KeySpec& spec, bool match_focus, std::string_view cmdline) {
207 std::lock_guard<std::mutex> l(lock);
208 if (!bindings.contains(spec.sym))
209 return false;
210 auto& binds = bindings[spec.sym];
211
212 auto new_end = std::remove_if(binds.begin(), binds.end(), [match_focus, spec, &cmdline](const auto& v) {
213 return v.spec.sym == spec.sym
214 && v.spec.modifiers == spec.modifiers
215 && (!match_focus || v.spec.focus == spec.focus)
216 && (cmdline.empty() || v.cmdline == cmdline);
217 });
218 if (new_end == binds.end())
219 return false; // No bindings removed
220
221 binds.erase(new_end, binds.end());
222 return true;
223}
224
225bool HotkeyManager::removeKeybind(std::string keyspec, bool match_focus, std::string_view cmdline) {
226 std::optional<KeySpec> spec_opt = KeySpec::parse(std::move(keyspec));

Callers 3

keybindingMethod · 0.80
hotkey_removeKeybindFunction · 0.80
cleanupHotkeysFunction · 0.80

Calls 5

containsMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
eraseMethod · 0.45

Tested by

no test coverage detected