diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-03-30 21:21:17 +0200 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-06-10 19:40:41 +0300 |
commit | c3adc244d7bb9cd9104dbf63919a29503b8030f7 (patch) | |
tree | fd2e0a9f78fdcc980a0223113bf8b857daa40bb8 | |
parent | a774aaebf645be8b366a83dace61acdf958602de (diff) |
ui: Implement fmt::Display for Key
-rw-r--r-- | ui/src/components/utilities.rs | 2 | ||||
-rw-r--r-- | ui/src/terminal/keys.rs | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/ui/src/components/utilities.rs b/ui/src/components/utilities.rs index 9d126ecd..bab024b6 100644 --- a/ui/src/components/utilities.rs +++ b/ui/src/components/utilities.rs @@ -964,7 +964,7 @@ impl Component for Tabbed { false, ); write_string_to_grid( - &format!("{:?}", v), + &format!("{}", v), grid, Color::Default, Color::Default, diff --git a/ui/src/terminal/keys.rs b/ui/src/terminal/keys.rs index c4062898..a5294a93 100644 --- a/ui/src/terminal/keys.rs +++ b/ui/src/terminal/keys.rs @@ -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()) |