| 97 | |
| 98 | impl 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 | |
| 137 | pub struct KeybindRegistry { |