From 5c910bc6cf193725575ef6146dcc8620e7a4a800 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 22 Jul 2020 22:08:50 +0530 Subject: remove debug key binds, add :write command --- src/app/impl_self.rs | 2 +- src/app/impl_view.rs | 11 ----------- src/command.rs | 3 +++ 3 files changed, 4 insertions(+), 12 deletions(-) diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index 7eae853..cf0e97f 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs @@ -257,7 +257,7 @@ impl App { self.message.set_message("help |commands|keys") } } - Command::Quit => self.save_state(), + Command::Quit | Command::Write => self.save_state(), Command::MonthNext => self.sift_forward(), Command::MonthPrev => self.sift_backward(), Command::Blank => {} diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index b8c4589..0dfd20b 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs @@ -102,17 +102,6 @@ impl View for App { self.set_focus(Absolute::Down); return EventResult::Consumed(None); } - Event::Char('w') => { - // helper bind to test write to file - let j = serde_json::to_string_pretty(&self.habits).unwrap(); - let mut file = File::create("foo.txt").unwrap(); - file.write_all(j.as_bytes()).unwrap(); - return EventResult::Consumed(None); - } - Event::Char('q') => { - self.save_state(); - return EventResult::with_cb(|s| s.quit()); - } Event::Char('v') => { if self.habits.is_empty() { return EventResult::Consumed(None); diff --git a/src/command.rs b/src/command.rs index 850261c..38d48e9 100644 --- a/src/command.rs +++ b/src/command.rs @@ -17,6 +17,7 @@ static COMMANDS: &'static [&'static str] = &[ "month-prev", "month-next", "quit", + "write", "help", ]; @@ -113,6 +114,7 @@ pub enum Command { TrackUp(String), TrackDown(String), Help(Option), + Write, Quit, Blank, } @@ -197,6 +199,7 @@ impl Command { "mprev" | "month-prev" => return Ok(Command::MonthPrev), "mnext" | "month-next" => return Ok(Command::MonthNext), "q" | "quit" => return Ok(Command::Quit), + "w" | "write" => return Ok(Command::Write), "" => return Ok(Command::Blank), s => return Err(CommandLineError::InvalidCommand(s.into())), } -- cgit v1.2.3