aboutsummaryrefslogtreecommitdiff
path: root/src/app.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app.rs')
-rw-r--r--src/app.rs29
1 files changed, 26 insertions, 3 deletions
diff --git a/src/app.rs b/src/app.rs
index f39ae3c..1240877 100644
--- a/src/app.rs
+++ b/src/app.rs
@@ -111,7 +111,7 @@ impl App {
111 fn status(&self) -> StatusLine { 111 fn status(&self) -> StatusLine {
112 let today = chrono::Local::now().naive_utc().date(); 112 let today = chrono::Local::now().naive_utc().date();
113 let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>(); 113 let remaining = self.habits.iter().map(|h| h.remaining(today)).sum::<u32>();
114 let total = self.habits.iter().map(|h| h.total()).sum::<u32>(); 114 let total = self.habits.iter().map(|h| h.goal()).sum::<u32>();
115 let completed = total - remaining; 115 let completed = total - remaining;
116 116
117 let timestamp = if self.view_month_offset == 0 { 117 let timestamp = if self.view_month_offset == 0 {
@@ -124,7 +124,7 @@ impl App {
124 let months = self.view_month_offset; 124 let months = self.view_month_offset;
125 format!( 125 format!(
126 "{:>width$}", 126 "{:>width$}",
127 format!("{} months ago", self.view_month_offset), 127 format!("{} months ago", months),
128 width = CONFIGURATION.view_width * CONFIGURATION.grid_width 128 width = CONFIGURATION.view_width * CONFIGURATION.grid_width
129 ) 129 )
130 }; 130 };
@@ -226,7 +226,7 @@ impl View for App {
226 let view_height = CONFIGURATION.view_height; 226 let view_height = CONFIGURATION.view_height;
227 let width = { 227 let width = {
228 if self.habits.len() > 0 { 228 if self.habits.len() > 0 {
229 grid_width * view_width 229 grid_width * (view_width + 2)
230 } else { 230 } else {
231 0 231 0
232 } 232 }
@@ -283,6 +283,29 @@ impl View for App {
283 self.save_state(); 283 self.save_state();
284 return EventResult::with_cb(|s| s.quit()); 284 return EventResult::with_cb(|s| s.quit());
285 } 285 }
286 Event::Char('v') => {
287 if self.habits.is_empty() {
288 return EventResult::Consumed(None);
289 }
290 if self.habits[self.focus].view_mode() == ViewMode::Month {
291 self.set_mode(ViewMode::Day)
292 } else {
293 self.set_mode(ViewMode::Month)
294 }
295 return EventResult::Consumed(None);
296 }
297 Event::Char('V') => {
298 for habit in self.habits.iter_mut() {
299 habit.set_view_mode(ViewMode::Month);
300 }
301 return EventResult::Consumed(None);
302 }
303 Event::Key(Key::Esc) => {
304 for habit in self.habits.iter_mut() {
305 habit.set_view_mode(ViewMode::Day);
306 }
307 return EventResult::Consumed(None);
308 }
286 309
287 /* We want sifting to be an app level function, 310 /* We want sifting to be an app level function,
288 * that later trickles down into each habit 311 * that later trickles down into each habit