diff options
author | Akshay <[email protected]> | 2020-07-04 15:57:09 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-04 15:57:09 +0100 |
commit | d51b80c27041513df86116c1c5036b9052d65f2f (patch) | |
tree | 453eda2dbe60f6d8a62d6f63633bc3125ed2fe27 /src | |
parent | b1b8369fe5621ff5b2222977bb357bec15a911e2 (diff) |
add quit command
Diffstat (limited to 'src')
-rw-r--r-- | src/app.rs | 13 | ||||
-rw-r--r-- | src/command.rs | 2 |
2 files changed, 10 insertions, 5 deletions
@@ -192,6 +192,12 @@ impl App { | |||
192 | } | 192 | } |
193 | Command::MonthNext => self.sift_forward(), | 193 | Command::MonthNext => self.sift_forward(), |
194 | Command::MonthPrev => self.sift_backward(), | 194 | Command::MonthPrev => self.sift_backward(), |
195 | |||
196 | // we can get away with calling an event here, | ||
197 | // saves us some writing | ||
198 | Command::Quit => { | ||
199 | self.on_event(Event::Char('q')); | ||
200 | } | ||
195 | _ => { | 201 | _ => { |
196 | eprintln!("UNKNOWN COMMAND!"); | 202 | eprintln!("UNKNOWN COMMAND!"); |
197 | } | 203 | } |
@@ -284,7 +290,7 @@ impl View for App { | |||
284 | return EventResult::Consumed(None); | 290 | return EventResult::Consumed(None); |
285 | } | 291 | } |
286 | Event::Char('q') => { | 292 | Event::Char('q') => { |
287 | // self.save_state(); | 293 | self.save_state(); |
288 | return EventResult::with_cb(|s| s.quit()); | 294 | return EventResult::with_cb(|s| s.quit()); |
289 | } | 295 | } |
290 | 296 | ||
@@ -304,10 +310,7 @@ impl View for App { | |||
304 | * s down to the focused Habit We sift back to today | 310 | * s down to the focused Habit We sift back to today |
305 | * before performing any action, "refocusing" the cursor | 311 | * before performing any action, "refocusing" the cursor |
306 | * */ | 312 | * */ |
307 | _ => { | 313 | _ => self.habits[self.focus].on_event(e), |
308 | self.set_view_month_offset(0); | ||
309 | self.habits[self.focus].on_event(e) | ||
310 | } | ||
311 | } | 314 | } |
312 | } | 315 | } |
313 | } | 316 | } |
diff --git a/src/command.rs b/src/command.rs index f94eab8..d25608f 100644 --- a/src/command.rs +++ b/src/command.rs | |||
@@ -21,6 +21,7 @@ pub enum Command { | |||
21 | MonthPrev, | 21 | MonthPrev, |
22 | MonthNext, | 22 | MonthNext, |
23 | Delete(String), | 23 | Delete(String), |
24 | Quit, | ||
24 | Blank, | 25 | Blank, |
25 | } | 26 | } |
26 | 27 | ||
@@ -53,6 +54,7 @@ impl Command { | |||
53 | } | 54 | } |
54 | "mprev" | "month-prev" => return Command::MonthPrev, | 55 | "mprev" | "month-prev" => return Command::MonthPrev, |
55 | "mnext" | "month-next" => return Command::MonthNext, | 56 | "mnext" | "month-next" => return Command::MonthNext, |
57 | "q" | "quit" => return Command::Quit, | ||
56 | _ => return Command::Blank, | 58 | _ => return Command::Blank, |
57 | } | 59 | } |
58 | } | 60 | } |