(&self, name: &str, code: KeyCode, modifiers: KeyModifiers)
| 210 | } |
| 211 | |
| 212 | pub fn match_key(&self, name: &str, code: KeyCode, modifiers: KeyModifiers) -> bool { |
| 213 | let Some(kb) = self.bindings.get(name) else { |
| 214 | return false; |
| 215 | }; |
| 216 | |
| 217 | if kb.code == code && kb.modifiers == modifiers { |
| 218 | return true; |
| 219 | } |
| 220 | |
| 221 | // Terminal implementations can report Shift+Tab as either: |
| 222 | // - KeyCode::BackTab with no modifiers |
| 223 | // - KeyCode::Tab with SHIFT modifier |
| 224 | if kb.code == KeyCode::BackTab { |
| 225 | match (code, modifiers) { |
| 226 | (KeyCode::BackTab, mods) if mods.is_empty() || mods == KeyModifiers::SHIFT => { |
| 227 | return true; |
| 228 | } |
| 229 | (KeyCode::Tab, mods) if mods.contains(KeyModifiers::SHIFT) => { |
| 230 | return true; |
| 231 | } |
| 232 | _ => {} |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | false |
| 237 | } |
| 238 | |
| 239 | pub fn print(&self, name: &str) -> String { |
| 240 | self.bindings |
no test coverage detected