diff options
Diffstat (limited to 'src/app.rs')
-rw-r--r-- | src/app.rs | 12 |
1 files changed, 7 insertions, 5 deletions
@@ -1,17 +1,17 @@ | |||
1 | use std::default::Default; | 1 | use std::default::Default; |
2 | use std::f64; | 2 | use std::f64; |
3 | use std::time::Duration; | ||
4 | use std::fs::{File, OpenOptions}; | 3 | use std::fs::{File, OpenOptions}; |
5 | use std::io::prelude::*; | 4 | use std::io::prelude::*; |
6 | use std::path::PathBuf; | 5 | use std::path::PathBuf; |
7 | use std::sync::mpsc::{channel, Receiver}; | 6 | use std::sync::mpsc::{channel, Receiver}; |
7 | use std::time::Duration; | ||
8 | 8 | ||
9 | use chrono::Local; | 9 | use chrono::Local; |
10 | use cursive::direction::{Absolute, Direction}; | 10 | use cursive::direction::{Absolute, Direction}; |
11 | use cursive::event::{Event, EventResult, Key}; | 11 | use cursive::event::{Event, EventResult, Key}; |
12 | use cursive::view::View; | 12 | use cursive::view::View; |
13 | use cursive::{Printer, Vec2}; | 13 | use cursive::{Printer, Vec2}; |
14 | use notify::{watcher, RecursiveMode, Watcher, DebouncedEvent, INotifyWatcher}; | 14 | use notify::{watcher, DebouncedEvent, INotifyWatcher, RecursiveMode, Watcher}; |
15 | 15 | ||
16 | use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode}; | 16 | use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode}; |
17 | use crate::utils; | 17 | use crate::utils; |
@@ -40,9 +40,11 @@ impl App { | |||
40 | pub fn new() -> Self { | 40 | pub fn new() -> Self { |
41 | let (tx, rx) = channel(); | 41 | let (tx, rx) = channel(); |
42 | let mut watcher = watcher(tx, Duration::from_secs(1)).unwrap(); | 42 | let mut watcher = watcher(tx, Duration::from_secs(1)).unwrap(); |
43 | watcher.watch(utils::auto_habit_file(), RecursiveMode::Recursive).unwrap_or_else(|e| { | 43 | watcher |
44 | panic!("Unable to start file watcher: {}", e); | 44 | .watch(utils::auto_habit_file(), RecursiveMode::Recursive) |
45 | }); | 45 | .unwrap_or_else(|e| { |
46 | panic!("Unable to start file watcher: {}", e); | ||
47 | }); | ||
46 | return App { | 48 | return App { |
47 | habits: vec![], | 49 | habits: vec![], |
48 | focus: 0, | 50 | focus: 0, |