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/app.rs | |
parent | b1b8369fe5621ff5b2222977bb357bec15a911e2 (diff) |
add quit command
Diffstat (limited to 'src/app.rs')
-rw-r--r-- | src/app.rs | 13 |
1 files changed, 8 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 | } |