aboutsummaryrefslogtreecommitdiff
path: root/src/habit/count.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-01-25 09:24:51 +0000
committerAkshay <[email protected]>2021-01-25 09:24:51 +0000
commitcd03d732b1f0df6c020a94135db2db4b690a4937 (patch)
tree94da0cfb56711abb1d8344d1804882c93201902d /src/habit/count.rs
parent665fd3fb61891b73175690158cde38cf7f94ebc7 (diff)
handle cursor events and entry
Diffstat (limited to 'src/habit/count.rs')
-rw-r--r--src/habit/count.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/habit/count.rs b/src/habit/count.rs
index d351758..b14354c 100644
--- a/src/habit/count.rs
+++ b/src/habit/count.rs
@@ -1,8 +1,10 @@
1use std::collections::HashMap; 1use std::collections::HashMap;
2 2
3use chrono::NaiveDate; 3use chrono::NaiveDate;
4use cursive::direction::Absolute;
4use serde::{Deserialize, Serialize}; 5use serde::{Deserialize, Serialize};
5 6
7use crate::app::Cursor;
6use crate::habit::prelude::default_auto; 8use crate::habit::prelude::default_auto;
7use crate::habit::traits::Habit; 9use crate::habit::traits::Habit;
8use crate::habit::{TrackEvent, ViewMode}; 10use crate::habit::{TrackEvent, ViewMode};
@@ -20,6 +22,9 @@ pub struct Count {
20 view_month_offset: u32, 22 view_month_offset: u32,
21 23
22 #[serde(skip)] 24 #[serde(skip)]
25 cursor: Cursor,
26
27 #[serde(skip)]
23 view_mode: ViewMode, 28 view_mode: ViewMode,
24} 29}
25 30
@@ -31,6 +36,7 @@ impl Count {
31 goal, 36 goal,
32 auto, 37 auto,
33 view_month_offset: 0, 38 view_month_offset: 0,
39 cursor: Cursor::new(),
34 view_mode: ViewMode::Day, 40 view_mode: ViewMode::Day,
35 }; 41 };
36 } 42 }
@@ -101,6 +107,12 @@ impl Habit for Count {
101 fn view_month_offset(&self) -> u32 { 107 fn view_month_offset(&self) -> u32 {
102 self.view_month_offset 108 self.view_month_offset
103 } 109 }
110 fn move_cursor(&mut self, d: Absolute) {
111 self.cursor.do_move(d);
112 }
113 fn cursor(&self) -> Cursor {
114 self.cursor
115 }
104 fn set_view_mode(&mut self, mode: ViewMode) { 116 fn set_view_mode(&mut self, mode: ViewMode) {
105 self.view_mode = mode; 117 self.view_mode = mode;
106 } 118 }