diff options
author | Akshay <[email protected]> | 2021-02-06 13:30:40 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2021-02-06 13:30:40 +0000 |
commit | 77368eed146ec8278609e04e395c7ef04c386313 (patch) | |
tree | 440eed647438cd8de03e91609e1daa43caf04bca /src/habit/bit.rs | |
parent | 9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 (diff) |
deprecate view_month_offset in favor of cursor
Diffstat (limited to 'src/habit/bit.rs')
-rw-r--r-- | src/habit/bit.rs | 37 |
1 files changed, 8 insertions, 29 deletions
diff --git a/src/habit/bit.rs b/src/habit/bit.rs index 7fe6fd9..da64ece 100644 --- a/src/habit/bit.rs +++ b/src/habit/bit.rs | |||
@@ -1,13 +1,12 @@ | |||
1 | use std::collections::HashMap; | 1 | use std::collections::HashMap; |
2 | use std::default::Default; | ||
2 | 3 | ||
3 | use chrono::NaiveDate; | 4 | use chrono::NaiveDate; |
4 | use cursive::direction::Absolute; | ||
5 | use serde::{Deserialize, Serialize}; | 5 | use serde::{Deserialize, Serialize}; |
6 | 6 | ||
7 | use crate::app::Cursor; | ||
8 | use crate::habit::prelude::default_auto; | 7 | use crate::habit::prelude::default_auto; |
9 | use crate::habit::traits::Habit; | 8 | use crate::habit::traits::Habit; |
10 | use crate::habit::{TrackEvent, ViewMode}; | 9 | use crate::habit::{InnerData, TrackEvent}; |
11 | use crate::CONFIGURATION; | 10 | use crate::CONFIGURATION; |
12 | 11 | ||
13 | #[derive(Copy, Clone, Debug, Serialize, Deserialize)] | 12 | #[derive(Copy, Clone, Debug, Serialize, Deserialize)] |
@@ -44,13 +43,7 @@ pub struct Bit { | |||
44 | auto: bool, | 43 | auto: bool, |
45 | 44 | ||
46 | #[serde(skip)] | 45 | #[serde(skip)] |
47 | view_month_offset: u32, | 46 | inner_data: InnerData, |
48 | |||
49 | #[serde(skip)] | ||
50 | cursor: Cursor, | ||
51 | |||
52 | #[serde(skip)] | ||
53 | view_mode: ViewMode, | ||
54 | } | 47 | } |
55 | 48 | ||
56 | impl Bit { | 49 | impl Bit { |
@@ -60,9 +53,7 @@ impl Bit { | |||
60 | stats: HashMap::new(), | 53 | stats: HashMap::new(), |
61 | goal: CustomBool(true), | 54 | goal: CustomBool(true), |
62 | auto, | 55 | auto, |
63 | view_month_offset: 0, | 56 | inner_data: Default::default(), |
64 | cursor: Cursor::new(), | ||
65 | view_mode: ViewMode::Day, | ||
66 | }; | 57 | }; |
67 | } | 58 | } |
68 | } | 59 | } |
@@ -124,23 +115,11 @@ impl Habit for Bit { | |||
124 | } | 115 | } |
125 | } | 116 | } |
126 | } | 117 | } |
127 | fn set_view_month_offset(&mut self, offset: u32) { | 118 | fn inner_data_ref(&self) -> &InnerData { |
128 | self.view_month_offset = offset; | 119 | &self.inner_data |
129 | } | ||
130 | fn view_month_offset(&self) -> u32 { | ||
131 | self.view_month_offset | ||
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 | } | ||
139 | fn set_view_mode(&mut self, mode: ViewMode) { | ||
140 | self.view_mode = mode; | ||
141 | } | 120 | } |
142 | fn view_mode(&self) -> ViewMode { | 121 | fn inner_data_mut_ref(&mut self) -> &mut InnerData { |
143 | self.view_mode | 122 | &mut self.inner_data |
144 | } | 123 | } |
145 | fn is_auto(&self) -> bool { | 124 | fn is_auto(&self) -> bool { |
146 | self.auto | 125 | self.auto |