aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/app/impl_self.rs2
-rw-r--r--src/app/impl_view.rs11
-rw-r--r--src/command.rs3
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 {
257 self.message.set_message("help <command>|commands|keys") 257 self.message.set_message("help <command>|commands|keys")
258 } 258 }
259 } 259 }
260 Command::Quit => self.save_state(), 260 Command::Quit | Command::Write => self.save_state(),
261 Command::MonthNext => self.sift_forward(), 261 Command::MonthNext => self.sift_forward(),
262 Command::MonthPrev => self.sift_backward(), 262 Command::MonthPrev => self.sift_backward(),
263 Command::Blank => {} 263 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 {
102 self.set_focus(Absolute::Down); 102 self.set_focus(Absolute::Down);
103 return EventResult::Consumed(None); 103 return EventResult::Consumed(None);
104 } 104 }
105 Event::Char('w') => {
106 // helper bind to test write to file
107 let j = serde_json::to_string_pretty(&self.habits).unwrap();
108 let mut file = File::create("foo.txt").unwrap();
109 file.write_all(j.as_bytes()).unwrap();
110 return EventResult::Consumed(None);
111 }
112 Event::Char('q') => {
113 self.save_state();
114 return EventResult::with_cb(|s| s.quit());
115 }
116 Event::Char('v') => { 105 Event::Char('v') => {
117 if self.habits.is_empty() { 106 if self.habits.is_empty() {
118 return EventResult::Consumed(None); 107 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] = &[
17 "month-prev", 17 "month-prev",
18 "month-next", 18 "month-next",
19 "quit", 19 "quit",
20 "write",
20 "help", 21 "help",
21]; 22];
22 23
@@ -113,6 +114,7 @@ pub enum Command {
113 TrackUp(String), 114 TrackUp(String),
114 TrackDown(String), 115 TrackDown(String),
115 Help(Option<String>), 116 Help(Option<String>),
117 Write,
116 Quit, 118 Quit,
117 Blank, 119 Blank,
118} 120}
@@ -197,6 +199,7 @@ impl Command {
197 "mprev" | "month-prev" => return Ok(Command::MonthPrev), 199 "mprev" | "month-prev" => return Ok(Command::MonthPrev),
198 "mnext" | "month-next" => return Ok(Command::MonthNext), 200 "mnext" | "month-next" => return Ok(Command::MonthNext),
199 "q" | "quit" => return Ok(Command::Quit), 201 "q" | "quit" => return Ok(Command::Quit),
202 "w" | "write" => return Ok(Command::Write),
200 "" => return Ok(Command::Blank), 203 "" => return Ok(Command::Blank),
201 s => return Err(CommandLineError::InvalidCommand(s.into())), 204 s => return Err(CommandLineError::InvalidCommand(s.into())),
202 } 205 }