From 8a1dd86155823455e71ca0f73673214073a8a269 Mon Sep 17 00:00:00 2001 From: Akshay Date: Sun, 19 Jul 2020 14:56:39 +0530 Subject: add startup hint, fix watcher panics --- src/app/impl_view.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'src/app/impl_view.rs') diff --git a/src/app/impl_view.rs b/src/app/impl_view.rs index 0a6bce6..892b00c 100644 --- a/src/app/impl_view.rs +++ b/src/app/impl_view.rs @@ -5,7 +5,7 @@ use std::path::PathBuf; use cursive::direction::{Absolute, Direction}; use cursive::event::{Event, EventResult, Key}; -use cursive::theme::{Color, Style}; +use cursive::theme::Color; use cursive::view::View; use cursive::{Printer, Vec2}; use notify::DebouncedEvent; @@ -48,23 +48,16 @@ impl View for App { let grid_width = CONFIGURATION.grid_width; let view_width = CONFIGURATION.view_width; let view_height = CONFIGURATION.view_height; - let width = { - if self.habits.len() > 0 { - grid_width * (view_width + 2) - } else { - 0 - } - }; + let width = grid_width * (view_width + 2); let height = { if self.habits.len() > 0 { (view_height as f64 * (self.habits.len() as f64 / grid_width as f64).ceil()) as usize - + 2 // to acoomodate statusline and message line } else { 0 } }; - Vec2::new(width, height) + Vec2::new(width, height + 2) } fn take_focus(&mut self, _: Direction) -> bool { @@ -89,6 +82,9 @@ impl View for App { } _ => {} }; + if self.habits.is_empty() { + return EventResult::Ignored; + } match e { Event::Key(Key::Right) | Event::Key(Key::Tab) | Event::Char('l') => { self.set_focus(Absolute::Right); -- cgit v1.2.3