diff options
Diffstat (limited to 'src/habit/traits.rs')
-rw-r--r-- | src/habit/traits.rs | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/src/habit/traits.rs b/src/habit/traits.rs index 74fd00b..289fd95 100644 --- a/src/habit/traits.rs +++ b/src/habit/traits.rs | |||
@@ -1,10 +1,11 @@ | |||
1 | use chrono::NaiveDate; | 1 | use chrono::NaiveDate; |
2 | use cursive::direction::Direction; | 2 | use cursive::direction::{Absolute, Direction}; |
3 | use cursive::event::{Event, EventResult}; | 3 | use cursive::event::{Event, EventResult}; |
4 | use cursive::{Printer, Vec2}; | 4 | use cursive::{Printer, Vec2}; |
5 | 5 | ||
6 | use typetag; | 6 | use typetag; |
7 | 7 | ||
8 | use crate::app::Cursor; | ||
8 | use crate::habit::{Bit, Count, TrackEvent, ViewMode}; | 9 | use crate::habit::{Bit, Count, TrackEvent, ViewMode}; |
9 | use crate::views::ShadowView; | 10 | use crate::views::ShadowView; |
10 | 11 | ||
@@ -24,6 +25,9 @@ pub trait Habit { | |||
24 | fn set_view_month_offset(&mut self, offset: u32); | 25 | fn set_view_month_offset(&mut self, offset: u32); |
25 | fn view_month_offset(&self) -> u32; | 26 | fn view_month_offset(&self) -> u32; |
26 | 27 | ||
28 | fn move_cursor(&mut self, d: Absolute); | ||
29 | fn cursor(&self) -> Cursor; | ||
30 | |||
27 | fn set_view_mode(&mut self, mode: ViewMode); | 31 | fn set_view_mode(&mut self, mode: ViewMode); |
28 | fn view_mode(&self) -> ViewMode; | 32 | fn view_mode(&self) -> ViewMode; |
29 | 33 | ||
@@ -44,6 +48,9 @@ pub trait HabitWrapper: erased_serde::Serialize { | |||
44 | fn set_view_month_offset(&mut self, offset: u32); | 48 | fn set_view_month_offset(&mut self, offset: u32); |
45 | fn view_month_offset(&self) -> u32; | 49 | fn view_month_offset(&self) -> u32; |
46 | 50 | ||
51 | fn move_cursor(&mut self, d: Absolute); | ||
52 | fn cursor(&self) -> Cursor; | ||
53 | |||
47 | fn set_view_mode(&mut self, mode: ViewMode); | 54 | fn set_view_mode(&mut self, mode: ViewMode); |
48 | fn view_mode(&self) -> ViewMode; | 55 | fn view_mode(&self) -> ViewMode; |
49 | 56 | ||
@@ -87,6 +94,12 @@ macro_rules! auto_habit_impl { | |||
87 | fn view_month_offset(&self) -> u32 { | 94 | fn view_month_offset(&self) -> u32 { |
88 | Habit::view_month_offset(self) | 95 | Habit::view_month_offset(self) |
89 | } | 96 | } |
97 | fn move_cursor(&mut self, d: Absolute) { | ||
98 | Habit::move_cursor(self, d) | ||
99 | } | ||
100 | fn cursor(&self) -> Cursor { | ||
101 | Habit::cursor(self) | ||
102 | } | ||
90 | fn set_view_mode(&mut self, mode: ViewMode) { | 103 | fn set_view_mode(&mut self, mode: ViewMode) { |
91 | Habit::set_view_mode(self, mode) | 104 | Habit::set_view_mode(self, mode) |
92 | } | 105 | } |