ui: Implement fmt::Display for Key
parent
a774aaebf6
commit
c3adc244d7
|
@ -964,7 +964,7 @@ impl Component for Tabbed {
|
|||
false,
|
||||
);
|
||||
write_string_to_grid(
|
||||
&format!("{:?}", v),
|
||||
&format!("{}", v),
|
||||
grid,
|
||||
Color::Default,
|
||||
Color::Default,
|
||||
|
|
|
@ -70,6 +70,22 @@ pub enum Key {
|
|||
Paste(String),
|
||||
}
|
||||
|
||||
impl fmt::Display for Key {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
use Key::*;
|
||||
match self {
|
||||
F(n) => write!(f, "F{}", n),
|
||||
Char('\t') => write!(f, "Tab"),
|
||||
Char('\n') => write!(f, "Enter"),
|
||||
Char(c) => write!(f, "{}", c),
|
||||
Alt(c) => write!(f, "M-{}", c),
|
||||
Ctrl(c) => write!(f, "C-{}", c),
|
||||
Paste(_) => write!(f, "Pasted buf"),
|
||||
a => write!(f, "{}", stringify!(a)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a String> for Key {
|
||||
fn from(v: &'a String) -> Self {
|
||||
Key::Paste(v.to_string())
|
||||
|
|
Loading…
Reference in New Issue