aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_self.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/impl_self.rs')
-rw-r--r--src/app/impl_self.rs20
1 files changed, 5 insertions, 15 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index 2b115a0..744f906 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -16,24 +16,20 @@ use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode};
16use crate::utils; 16use crate::utils;
17use crate::CONFIGURATION; 17use crate::CONFIGURATION;
18 18
19use crate::app::{App, Message, MessageKind, StatusLine}; 19use crate::app::{App, MessageKind, StatusLine};
20 20
21impl App { 21impl App {
22 pub fn new() -> Self { 22 pub fn new() -> Self {
23 let (tx, rx) = channel(); 23 let (tx, rx) = channel();
24 let mut watcher = watcher(tx, Duration::from_secs(1)).unwrap(); 24 let mut watcher = watcher(tx, Duration::from_secs(1)).unwrap();
25 watcher 25 watcher.watch(utils::auto_habit_file(), RecursiveMode::Recursive);
26 .watch(utils::auto_habit_file(), RecursiveMode::Recursive)
27 .unwrap_or_else(|e| {
28 panic!("Unable to start file watcher: {}", e);
29 });
30 return App { 26 return App {
31 habits: vec![], 27 habits: vec![],
32 focus: 0, 28 focus: 0,
33 _file_watcher: watcher, 29 _file_watcher: watcher,
34 file_event_recv: rx, 30 file_event_recv: rx,
35 view_month_offset: 0, 31 view_month_offset: 0,
36 message: Message::default(), 32 message: "Type :add <habit-name> <goal> to get started, Ctrl-L to dismiss".into(),
37 }; 33 };
38 } 34 }
39 35
@@ -147,15 +143,9 @@ impl App {
147 143
148 pub fn max_size(&self) -> Vec2 { 144 pub fn max_size(&self) -> Vec2 {
149 let grid_width = CONFIGURATION.grid_width; 145 let grid_width = CONFIGURATION.grid_width;
150 let width = { 146 let width = grid_width * CONFIGURATION.view_width;
151 if self.habits.len() > 0 {
152 grid_width * CONFIGURATION.view_width
153 } else {
154 0
155 }
156 };
157 let height = { 147 let height = {
158 if self.habits.len() > 0 { 148 if !self.habits.is_empty() {
159 (CONFIGURATION.view_height as f64 149 (CONFIGURATION.view_height as f64
160 * (self.habits.len() as f64 / grid_width as f64).ceil()) 150 * (self.habits.len() as f64 / grid_width as f64).ceil())
161 as usize 151 as usize