diff options
Diffstat (limited to 'src/app/impl_view.rs')
-rw-r--r-- | src/app/impl_view.rs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index 395cac4..c369d8f 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs | |||
@@ -95,11 +95,29 @@ impl View for App { | |||
95 | self.set_focus(Absolute::Down); | 95 | self.set_focus(Absolute::Down); |
96 | return EventResult::Consumed(None); | 96 | return EventResult::Consumed(None); |
97 | } | 97 | } |
98 | |||
99 | Event::Char('K') => { | ||
100 | self.move_cursor(Absolute::Up); | ||
101 | return EventResult::Consumed(None); | ||
102 | } | ||
103 | Event::Char('H') => { | ||
104 | self.move_cursor(Absolute::Left); | ||
105 | return EventResult::Consumed(None); | ||
106 | } | ||
107 | Event::Char('J') => { | ||
108 | self.move_cursor(Absolute::Down); | ||
109 | return EventResult::Consumed(None); | ||
110 | } | ||
111 | Event::Char('L') => { | ||
112 | self.move_cursor(Absolute::Right); | ||
113 | return EventResult::Consumed(None); | ||
114 | } | ||
115 | |||
98 | Event::Char('v') => { | 116 | Event::Char('v') => { |
99 | if self.habits.is_empty() { | 117 | if self.habits.is_empty() { |
100 | return EventResult::Consumed(None); | 118 | return EventResult::Consumed(None); |
101 | } | 119 | } |
102 | if self.habits[self.focus].view_mode() == ViewMode::Week { | 120 | if self.habits[self.focus].inner_data_ref().view_mode() == ViewMode::Week { |
103 | self.set_mode(ViewMode::Day) | 121 | self.set_mode(ViewMode::Day) |
104 | } else { | 122 | } else { |
105 | self.set_mode(ViewMode::Week) | 123 | self.set_mode(ViewMode::Week) |
@@ -108,14 +126,15 @@ impl View for App { | |||
108 | } | 126 | } |
109 | Event::Char('V') => { | 127 | Event::Char('V') => { |
110 | for habit in self.habits.iter_mut() { | 128 | for habit in self.habits.iter_mut() { |
111 | habit.set_view_mode(ViewMode::Week); | 129 | habit.inner_data_mut_ref().set_view_mode(ViewMode::Week); |
112 | } | 130 | } |
113 | return EventResult::Consumed(None); | 131 | return EventResult::Consumed(None); |
114 | } | 132 | } |
115 | Event::Key(Key::Esc) => { | 133 | Event::Key(Key::Esc) => { |
116 | for habit in self.habits.iter_mut() { | 134 | for habit in self.habits.iter_mut() { |
117 | habit.set_view_mode(ViewMode::Day); | 135 | habit.inner_data_mut_ref().set_view_mode(ViewMode::Day); |
118 | } | 136 | } |
137 | self.reset_cursor(); | ||
119 | return EventResult::Consumed(None); | 138 | return EventResult::Consumed(None); |
120 | } | 139 | } |
121 | 140 | ||
@@ -131,7 +150,7 @@ impl View for App { | |||
131 | return EventResult::Consumed(None); | 150 | return EventResult::Consumed(None); |
132 | } | 151 | } |
133 | Event::Char('}') => { | 152 | Event::Char('}') => { |
134 | self.set_view_month_offset(0); | 153 | self.reset_cursor(); |
135 | return EventResult::Consumed(None); | 154 | return EventResult::Consumed(None); |
136 | } | 155 | } |
137 | Event::CtrlChar('l') => { | 156 | Event::CtrlChar('l') => { |
@@ -141,14 +160,12 @@ impl View for App { | |||
141 | } | 160 | } |
142 | 161 | ||
143 | /* Every keybind that is not caught by App trickles | 162 | /* Every keybind that is not caught by App trickles |
144 | * down to the focused habit. We sift back to today | 163 | * down to the focused habit. |
145 | * before performing any action, "refocusing" the cursor | ||
146 | * */ | 164 | * */ |
147 | _ => { | 165 | _ => { |
148 | if self.habits.is_empty() { | 166 | if self.habits.is_empty() { |
149 | return EventResult::Ignored; | 167 | return EventResult::Ignored; |
150 | } | 168 | } |
151 | self.set_view_month_offset(0); | ||
152 | self.habits[self.focus].on_event(e) | 169 | self.habits[self.focus].on_event(e) |
153 | } | 170 | } |
154 | } | 171 | } |