| 230 | } |
| 231 | |
| 232 | std::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 | |
| 262 | std::vector<std::string> HotkeyManager::listKeybinds(std::string keyspec) { |
| 263 | std::optional<KeySpec> spec_opt = KeySpec::parse(std::move(keyspec)); |
no test coverage detected