aboutsummaryrefslogtreecommitdiff
path: root/src/app/impl_view.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/app/impl_view.rs')
-rw-r--r--src/app/impl_view.rs16
1 files changed, 6 insertions, 10 deletions
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;
5 5
6use cursive::direction::{Absolute, Direction}; 6use cursive::direction::{Absolute, Direction};
7use cursive::event::{Event, EventResult, Key}; 7use cursive::event::{Event, EventResult, Key};
8use cursive::theme::{Color, Style}; 8use cursive::theme::Color;
9use cursive::view::View; 9use cursive::view::View;
10use cursive::{Printer, Vec2}; 10use cursive::{Printer, Vec2};
11use notify::DebouncedEvent; 11use notify::DebouncedEvent;
@@ -48,23 +48,16 @@ impl View for App {
48 let grid_width = CONFIGURATION.grid_width; 48 let grid_width = CONFIGURATION.grid_width;
49 let view_width = CONFIGURATION.view_width; 49 let view_width = CONFIGURATION.view_width;
50 let view_height = CONFIGURATION.view_height; 50 let view_height = CONFIGURATION.view_height;
51 let width = { 51 let width = grid_width * (view_width + 2);
52 if self.habits.len() > 0 {
53 grid_width * (view_width + 2)
54 } else {
55 0
56 }
57 };
58 let height = { 52 let height = {
59 if self.habits.len() > 0 { 53 if self.habits.len() > 0 {
60 (view_height as f64 * (self.habits.len() as f64 / grid_width as f64).ceil()) 54 (view_height as f64 * (self.habits.len() as f64 / grid_width as f64).ceil())
61 as usize 55 as usize
62 + 2 // to acoomodate statusline and message line
63 } else { 56 } else {
64 0 57 0
65 } 58 }
66 }; 59 };
67 Vec2::new(width, height) 60 Vec2::new(width, height + 2)
68 } 61 }
69 62
70 fn take_focus(&mut self, _: Direction) -> bool { 63 fn take_focus(&mut self, _: Direction) -> bool {
@@ -89,6 +82,9 @@ impl View for App {
89 } 82 }
90 _ => {} 83 _ => {}
91 }; 84 };
85 if self.habits.is_empty() {
86 return EventResult::Ignored;
87 }
92 match e { 88 match e {
93 Event::Key(Key::Right) | Event::Key(Key::Tab) | Event::Char('l') => { 89 Event::Key(Key::Right) | Event::Key(Key::Tab) | Event::Char('l') => {
94 self.set_focus(Absolute::Right); 90 self.set_focus(Absolute::Right);