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

Method fmt

crates/opencode-tui/src/context/keybind.rs:99–134  ·  view source on GitHub ↗
(&self, f: &mut std::fmt::Formatter<'_>)

Source from the content-addressed store, hash-verified

97
98impl std::fmt::Display for Keybind {
99 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
100 let mut parts = Vec::new();
101
102 if self.modifiers.contains(KeyModifiers::CONTROL) {
103 parts.push("ctrl");
104 }
105 if self.modifiers.contains(KeyModifiers::ALT) {
106 parts.push("alt");
107 }
108 if self.modifiers.contains(KeyModifiers::SHIFT) {
109 parts.push("shift");
110 }
111
112 let key_str = match self.code {
113 KeyCode::Char(c) => c.to_string(),
114 KeyCode::Enter => "enter".to_string(),
115 KeyCode::Backspace => "backspace".to_string(),
116 KeyCode::Esc => "esc".to_string(),
117 KeyCode::Tab => "tab".to_string(),
118 KeyCode::BackTab => "shift+tab".to_string(),
119 KeyCode::Delete => "del".to_string(),
120 KeyCode::Home => "home".to_string(),
121 KeyCode::End => "end".to_string(),
122 KeyCode::PageUp => "pgup".to_string(),
123 KeyCode::PageDown => "pgdn".to_string(),
124 KeyCode::Up => "up".to_string(),
125 KeyCode::Down => "down".to_string(),
126 KeyCode::Left => "left".to_string(),
127 KeyCode::Right => "right".to_string(),
128 KeyCode::F(n) => format!("f{}", n),
129 _ => "?".to_string(),
130 };
131 parts.push(&key_str);
132
133 write!(f, "{}", parts.join("+"))
134 }
135}
136
137pub struct KeybindRegistry {

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
containsMethod · 0.80

Tested by

no test coverage detected