From 879b115d651b26d3935f5c95d06f426019dedcd3 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 21 Feb 2021 10:12:10 +0530 Subject: remove all instances of view_month_offset --- src/app/impl_self.rs | 1 - src/app/impl_view.rs | 5 ++--- src/app/mod.rs | 1 - src/theme.rs | 2 +- src/utils.rs | 4 ++-- src/views.rs | 1 - 6 files changed, 5 insertions(+), 9 deletions(-) (limited to 'src') 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 { focus: 0, _file_watcher: watcher, file_event_recv: rx, - view_month_offset: 0, cursor: Cursor::new(), message: Message::startup(), }; 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 { for habit in self.habits.iter_mut() { habit.inner_data_mut_ref().set_view_mode(ViewMode::Day); } + self.reset_cursor(); return EventResult::Consumed(None); } @@ -159,14 +160,12 @@ impl View for App { } /* Every keybind that is not caught by App trickles - * down to the focused habit. We sift back to today - * before performing any action, "refocusing" the cursor + * down to the focused habit. * */ _ => { if self.habits.is_empty() { return EventResult::Ignored; } - self.reset_cursor(); self.habits[self.focus].on_event(e) } } 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 { _file_watcher: RecommendedWatcher, file_event_recv: Receiver, focus: usize, - view_month_offset: u32, cursor: Cursor, message: Message, } 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 @@ use cursive::theme::Color::{self, *}; use cursive::theme::PaletteColor::*; -use cursive::theme::{BorderStyle, ColorStyle, Palette, Style, Theme}; +use cursive::theme::{BorderStyle, Palette, Theme}; pub fn pallete_gen() -> Palette { 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 { if let Ok(ref mut f) = File::open(&cf) { let mut j = String::new(); f.read_to_string(&mut j); - return toml::from_str(&j).unwrap(); + return toml::from_str(&j).unwrap_or_else(|e| panic!("Invalid config file: `{}`", e)); } else { if let Ok(dc) = toml::to_string(&AppConfig::default()) { match OpenOptions::new().create(true).write(true).open(&cf) { Ok(ref mut file) => file.write(dc.as_bytes()).unwrap(), - Err(_) => 0, + Err(_) => panic!("Unable to write config file to disk!"), }; } 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 let month = now.month(); let goal_reached_style = Style::from(CONFIGURATION.reached_color()); - let todo_style = Style::from(CONFIGURATION.todo_color()); let future_style = Style::from(CONFIGURATION.inactive_color()); let strikethrough = Style::from(Effect::Strikethrough); -- cgit v1.2.3