diff options
author | Griffin Smith <root@gws.fyi> | 2019-07-06T02·45-0400 |
---|---|---|
committer | Griffin Smith <root@gws.fyi> | 2019-07-06T02·45-0400 |
commit | de081d7b1d0b791b2e61f9cde7369ea11647e0ae (patch) | |
tree | 687236ac6ca2d094053fa43112d967554531de86 /src/types/command.rs |
an @-sign in a box
Diffstat (limited to 'src/types/command.rs')
-rw-r--r-- | src/types/command.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/types/command.rs b/src/types/command.rs new file mode 100644 index 000000000000..86f83a12c181 --- /dev/null +++ b/src/types/command.rs @@ -0,0 +1,23 @@ +use super::Direction; +use super::Direction::*; +use termion::event::Key; +use termion::event::Key::Char; + +pub enum Command { + Quit, + Move(Direction), +} + +impl Command { + pub fn from_key(k: Key) -> Option<Command> { + use Command::*; + match k { + Char('q') => Some(Quit), + Char('h') | Char('a') | Key::Left => Some(Move(Left)), + Char('k') | Char('w') | Key::Up => Some(Move(Up)), + Char('j') | Char('s') | Key::Down => Some(Move(Down)), + Char('l') | Char('d') | Key::Right => Some(Move(Right)), + _ => None, + } + } +} |