aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_self.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-01-25 09:24:51 +0000
committerAkshay <[email protected]>2021-01-25 09:24:51 +0000
commitcd03d732b1f0df6c020a94135db2db4b690a4937 (patch)
tree94da0cfb56711abb1d8344d1804882c93201902d /src/app/impl_self.rs
parent665fd3fb61891b73175690158cde38cf7f94ebc7 (diff)
handle cursor events and entry
Diffstat (limited to 'src/app/impl_self.rs')
-rw-r--r--src/app/impl_self.rs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index 1114d50..abf5209 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -15,7 +15,7 @@ use crate::command::{Command, CommandLineError};
15use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode}; 15use crate::habit::{Bit, Count, HabitWrapper, TrackEvent, ViewMode};
16use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH}; 16use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH};
17 17
18use crate::app::{App, MessageKind, StatusLine}; 18use crate::app::{App, Cursor, Message, MessageKind, StatusLine};
19 19
20impl App { 20impl App {
21 pub fn new() -> Self { 21 pub fn new() -> Self {
@@ -28,7 +28,8 @@ impl App {
28 _file_watcher: watcher, 28 _file_watcher: watcher,
29 file_event_recv: rx, 29 file_event_recv: rx,
30 view_month_offset: 0, 30 view_month_offset: 0,
31 message: "Type :add <habit-name> <goal> to get started, Ctrl-L to dismiss".into(), 31 cursor: Cursor::new(),
32 message: Message::startup(),
32 }; 33 };
33 } 34 }
34 35
@@ -85,6 +86,13 @@ impl App {
85 } 86 }
86 } 87 }
87 88
89 pub fn move_cursor(&mut self, d: Absolute) {
90 self.cursor.do_move(d);
91 for v in self.habits.iter_mut() {
92 v.move_cursor(d);
93 }
94 }
95
88 pub fn set_focus(&mut self, d: Absolute) { 96 pub fn set_focus(&mut self, d: Absolute) {
89 match d { 97 match d {
90 Absolute::Right => { 98 Absolute::Right => {
@@ -129,7 +137,7 @@ impl App {
129 format!("{}", Local::now().naive_local().date().format("%d/%b/%y"),) 137 format!("{}", Local::now().naive_local().date().format("%d/%b/%y"),)
130 } else { 138 } else {
131 let months = self.view_month_offset; 139 let months = self.view_month_offset;
132 format!("{}", format!("{} months ago", months),) 140 format!("{}", format!("{} month(s) ago", months),)
133 }; 141 };
134 142
135 StatusLine { 143 StatusLine {