aboutsummaryrefslogtreecommitdiff
path: root/src/habit/bit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/habit/bit.rs')
-rw-r--r--src/habit/bit.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/habit/bit.rs b/src/habit/bit.rs
index 2bbb0ac..7fe6fd9 100644
--- a/src/habit/bit.rs
+++ b/src/habit/bit.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};
@@ -45,6 +47,9 @@ pub struct Bit {
45 view_month_offset: u32, 47 view_month_offset: u32,
46 48
47 #[serde(skip)] 49 #[serde(skip)]
50 cursor: Cursor,
51
52 #[serde(skip)]
48 view_mode: ViewMode, 53 view_mode: ViewMode,
49} 54}
50 55
@@ -56,6 +61,7 @@ impl Bit {
56 goal: CustomBool(true), 61 goal: CustomBool(true),
57 auto, 62 auto,
58 view_month_offset: 0, 63 view_month_offset: 0,
64 cursor: Cursor::new(),
59 view_mode: ViewMode::Day, 65 view_mode: ViewMode::Day,
60 }; 66 };
61 } 67 }
@@ -124,6 +130,12 @@ impl Habit for Bit {
124 fn view_month_offset(&self) -> u32 { 130 fn view_month_offset(&self) -> u32 {
125 self.view_month_offset 131 self.view_month_offset
126 } 132 }
133 fn move_cursor(&mut self, d: Absolute) {
134 self.cursor.do_move(d);
135 }
136 fn cursor(&self) -> Cursor {
137 self.cursor
138 }
127 fn set_view_mode(&mut self, mode: ViewMode) { 139 fn set_view_mode(&mut self, mode: ViewMode) {
128 self.view_mode = mode; 140 self.view_mode = mode;
129 } 141 }