summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAkshay <nerdy@peppe.rs>2020-07-04 20:27:09 +0530
committerAkshay <nerdy@peppe.rs>2020-07-04 20:27:09 +0530
commitd51b80c27041513df86116c1c5036b9052d65f2f (patch)
tree453eda2dbe60f6d8a62d6f63633bc3125ed2fe27
parentb1b8369fe5621ff5b2222977bb357bec15a911e2 (diff)
add quit command
-rw-r--r--src/app.rs13
-rw-r--r--src/command.rs2
2 files changed, 10 insertions, 5 deletions
diff --git a/src/app.rs b/src/app.rs
index 7495dd8..44de5bb 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -192,6 +192,12 @@ impl App {
}
Command::MonthNext => self.sift_forward(),
Command::MonthPrev => self.sift_backward(),
+
+ // we can get away with calling an event here,
+ // saves us some writing
+ Command::Quit => {
+ self.on_event(Event::Char('q'));
+ }
_ => {
eprintln!("UNKNOWN COMMAND!");
}
@@ -284,7 +290,7 @@ impl View for App {
return EventResult::Consumed(None);
}
Event::Char('q') => {
- // self.save_state();
+ self.save_state();
return EventResult::with_cb(|s| s.quit());
}
@@ -304,10 +310,7 @@ impl View for App {
* s down to the focused Habit We sift back to today
* before performing any action, "refocusing" the cursor
* */
- _ => {
- self.set_view_month_offset(0);
- self.habits[self.focus].on_event(e)
- }
+ _ => self.habits[self.focus].on_event(e),
}
}
}
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 {
MonthPrev,
MonthNext,
Delete(String),
+ Quit,
Blank,
}
@@ -53,6 +54,7 @@ impl Command {
}
"mprev" | "month-prev" => return Command::MonthPrev,
"mnext" | "month-next" => return Command::MonthNext,
+ "q" | "quit" => return Command::Quit,
_ => return Command::Blank,
}
}