aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_view.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-02-06 13:30:40 +0000
committerAkshay <[email protected]>2021-02-21 05:13:14 +0000
commit53f7a679a0cf7a510de13d67cf370988f71c0d08 (patch)
treeb43b30df476d76d0a18feb7c6e7e00fd3ac4dae4 /src/app/impl_view.rs
parent9cdef4e296c77fb94d99553de05ba1aaa6c81ed8 (diff)
deprecate view_month_offset in favor of cursor
Diffstat (limited to 'src/app/impl_view.rs')
-rw-r--r--src/app/impl_view.rs21
1 files changed, 10 insertions, 11 deletions
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs
index 0ec47f1..c369d8f 100644
--- a/src/app/impl_view.rs
+++ b/src/app/impl_view.rs
@@ -96,19 +96,19 @@ impl View for App {
96 return EventResult::Consumed(None); 96 return EventResult::Consumed(None);
97 } 97 }
98 98
99 Event::Char('w') => { 99 Event::Char('K') => {
100 self.move_cursor(Absolute::Up); 100 self.move_cursor(Absolute::Up);
101 return EventResult::Consumed(None); 101 return EventResult::Consumed(None);
102 } 102 }
103 Event::Char('a') => { 103 Event::Char('H') => {
104 self.move_cursor(Absolute::Left); 104 self.move_cursor(Absolute::Left);
105 return EventResult::Consumed(None); 105 return EventResult::Consumed(None);
106 } 106 }
107 Event::Char('s') => { 107 Event::Char('J') => {
108 self.move_cursor(Absolute::Down); 108 self.move_cursor(Absolute::Down);
109 return EventResult::Consumed(None); 109 return EventResult::Consumed(None);
110 } 110 }
111 Event::Char('d') => { 111 Event::Char('L') => {
112 self.move_cursor(Absolute::Right); 112 self.move_cursor(Absolute::Right);
113 return EventResult::Consumed(None); 113 return EventResult::Consumed(None);
114 } 114 }
@@ -117,7 +117,7 @@ impl View for App {
117 if self.habits.is_empty() { 117 if self.habits.is_empty() {
118 return EventResult::Consumed(None); 118 return EventResult::Consumed(None);
119 } 119 }
120 if self.habits[self.focus].view_mode() == ViewMode::Week { 120 if self.habits[self.focus].inner_data_ref().view_mode() == ViewMode::Week {
121 self.set_mode(ViewMode::Day) 121 self.set_mode(ViewMode::Day)
122 } else { 122 } else {
123 self.set_mode(ViewMode::Week) 123 self.set_mode(ViewMode::Week)
@@ -126,14 +126,15 @@ impl View for App {
126 } 126 }
127 Event::Char('V') => { 127 Event::Char('V') => {
128 for habit in self.habits.iter_mut() { 128 for habit in self.habits.iter_mut() {
129 habit.set_view_mode(ViewMode::Week); 129 habit.inner_data_mut_ref().set_view_mode(ViewMode::Week);
130 } 130 }
131 return EventResult::Consumed(None); 131 return EventResult::Consumed(None);
132 } 132 }
133 Event::Key(Key::Esc) => { 133 Event::Key(Key::Esc) => {
134 for habit in self.habits.iter_mut() { 134 for habit in self.habits.iter_mut() {
135 habit.set_view_mode(ViewMode::Day); 135 habit.inner_data_mut_ref().set_view_mode(ViewMode::Day);
136 } 136 }
137 self.reset_cursor();
137 return EventResult::Consumed(None); 138 return EventResult::Consumed(None);
138 } 139 }
139 140
@@ -149,7 +150,7 @@ impl View for App {
149 return EventResult::Consumed(None); 150 return EventResult::Consumed(None);
150 } 151 }
151 Event::Char('}') => { 152 Event::Char('}') => {
152 self.set_view_month_offset(0); 153 self.reset_cursor();
153 return EventResult::Consumed(None); 154 return EventResult::Consumed(None);
154 } 155 }
155 Event::CtrlChar('l') => { 156 Event::CtrlChar('l') => {
@@ -159,14 +160,12 @@ impl View for App {
159 } 160 }
160 161
161 /* Every keybind that is not caught by App trickles 162 /* Every keybind that is not caught by App trickles
162 * down to the focused habit. We sift back to today 163 * down to the focused habit.
163 * before performing any action, "refocusing" the cursor
164 * */ 164 * */
165 _ => { 165 _ => {
166 if self.habits.is_empty() { 166 if self.habits.is_empty() {
167 return EventResult::Ignored; 167 return EventResult::Ignored;
168 } 168 }
169 self.set_view_month_offset(0);
170 self.habits[self.focus].on_event(e) 169 self.habits[self.focus].on_event(e)
171 } 170 }
172 } 171 }