aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-02-21 04:42:10 +0000
committerAkshay <[email protected]>2021-02-21 04:42:10 +0000
commit879b115d651b26d3935f5c95d06f426019dedcd3 (patch)
treebc013d60a48d4603ec496de26494e8ba5b3a86a4 /src
parent77368eed146ec8278609e04e395c7ef04c386313 (diff)
remove all instances of view_month_offsetcursor
Diffstat (limited to 'src')
-rw-r--r--src/app/impl_self.rs1
-rw-r--r--src/app/impl_view.rs5
-rw-r--r--src/app/mod.rs1
-rw-r--r--src/theme.rs2
-rw-r--r--src/utils.rs4
-rw-r--r--src/views.rs1
6 files changed, 5 insertions, 9 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs
index fec7219..d5f93ff 100644
--- a/src/app/impl_self.rs
+++ b/src/app/impl_self.rs
@@ -27,7 +27,6 @@ impl App {
27 focus: 0, 27 focus: 0,
28 _file_watcher: watcher, 28 _file_watcher: watcher,
29 file_event_recv: rx, 29 file_event_recv: rx,
30 view_month_offset: 0,
31 cursor: Cursor::new(), 30 cursor: Cursor::new(),
32 message: Message::startup(), 31 message: Message::startup(),
33 }; 32 };
diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs
index db05432..98f540c 100644
--- a/src/app/impl_view.rs
+++ b/src/app/impl_view.rs
@@ -134,6 +134,7 @@ impl View for App {
134 for habit in self.habits.iter_mut() { 134 for habit in self.habits.iter_mut() {
135 habit.inner_data_mut_ref().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
@@ -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.reset_cursor();
170 self.habits[self.focus].on_event(e) 169 self.habits[self.focus].on_event(e)
171 } 170 }
172 } 171 }
diff --git a/src/app/mod.rs b/src/app/mod.rs
index 9432f0d..726a656 100644
--- a/src/app/mod.rs
+++ b/src/app/mod.rs
@@ -21,7 +21,6 @@ pub struct App {
21 _file_watcher: RecommendedWatcher, 21 _file_watcher: RecommendedWatcher,
22 file_event_recv: Receiver<DebouncedEvent>, 22 file_event_recv: Receiver<DebouncedEvent>,
23 focus: usize, 23 focus: usize,
24 view_month_offset: u32,
25 cursor: Cursor, 24 cursor: Cursor,
26 message: Message, 25 message: Message,
27} 26}
diff --git a/src/theme.rs b/src/theme.rs
index 7ae9efc..879584c 100644
--- a/src/theme.rs
+++ b/src/theme.rs
@@ -1,6 +1,6 @@
1use cursive::theme::Color::{self, *}; 1use cursive::theme::Color::{self, *};
2use cursive::theme::PaletteColor::*; 2use cursive::theme::PaletteColor::*;
3use cursive::theme::{BorderStyle, ColorStyle, Palette, Style, Theme}; 3use cursive::theme::{BorderStyle, Palette, Theme};
4 4
5pub fn pallete_gen() -> Palette { 5pub fn pallete_gen() -> Palette {
6 let mut p = Palette::default(); 6 let mut p = Palette::default();
diff --git a/src/utils.rs b/src/utils.rs
index 2453aa6..f5a25c8 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -102,12 +102,12 @@ pub fn load_configuration_file() -> AppConfig {
102 if let Ok(ref mut f) = File::open(&cf) { 102 if let Ok(ref mut f) = File::open(&cf) {
103 let mut j = String::new(); 103 let mut j = String::new();
104 f.read_to_string(&mut j); 104 f.read_to_string(&mut j);
105 return toml::from_str(&j).unwrap(); 105 return toml::from_str(&j).unwrap_or_else(|e| panic!("Invalid config file: `{}`", e));
106 } else { 106 } else {
107 if let Ok(dc) = toml::to_string(&AppConfig::default()) { 107 if let Ok(dc) = toml::to_string(&AppConfig::default()) {
108 match OpenOptions::new().create(true).write(true).open(&cf) { 108 match OpenOptions::new().create(true).write(true).open(&cf) {
109 Ok(ref mut file) => file.write(dc.as_bytes()).unwrap(), 109 Ok(ref mut file) => file.write(dc.as_bytes()).unwrap(),
110 Err(_) => 0, 110 Err(_) => panic!("Unable to write config file to disk!"),
111 }; 111 };
112 } 112 }
113 return Default::default(); 113 return Default::default();
diff --git a/src/views.rs b/src/views.rs
index f02eb83..b90ce2b 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -41,7 +41,6 @@ where
41 let month = now.month(); 41 let month = now.month();
42 42
43 let goal_reached_style = Style::from(CONFIGURATION.reached_color()); 43 let goal_reached_style = Style::from(CONFIGURATION.reached_color());
44 let todo_style = Style::from(CONFIGURATION.todo_color());
45 let future_style = Style::from(CONFIGURATION.inactive_color()); 44 let future_style = Style::from(CONFIGURATION.inactive_color());
46 45
47 let strikethrough = Style::from(Effect::Strikethrough); 46 let strikethrough = Style::from(Effect::Strikethrough);