MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / match_key

Method match_key

crates/opencode-tui/src/context/keybind.rs:212–237  ·  view source on GitHub ↗
(&self, name: &str, code: KeyCode, modifiers: KeyModifiers)

Source from the content-addressed store, hash-verified

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

Callers 1

matches_keybindMethod · 0.80

Calls 3

is_emptyMethod · 0.80
containsMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected