diff options
author | Akshay <[email protected]> | 2021-05-13 18:01:26 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2021-05-13 18:01:26 +0100 |
commit | a9142b54a72bac4864ae1147a96fcf6896cee3d6 (patch) | |
tree | bb7e3cf5dafecc24c09d592b58c904b8aa7e26dc /src/app/impl_self.rs | |
parent | bf30b22665ef596f8627559bd8378d7ab6fbbd47 (diff) |
allow custom grid_size from toml filegrid-width
Diffstat (limited to 'src/app/impl_self.rs')
-rw-r--r-- | src/app/impl_self.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/app/impl_self.rs b/src/app/impl_self.rs index fad965a..b53cdcf 100644 --- a/src/app/impl_self.rs +++ b/src/app/impl_self.rs | |||
@@ -11,9 +11,10 @@ use cursive::direction::Absolute; | |||
11 | use cursive::Vec2; | 11 | use cursive::Vec2; |
12 | use notify::{watcher, RecursiveMode, Watcher}; | 12 | use notify::{watcher, RecursiveMode, Watcher}; |
13 | 13 | ||
14 | use crate::CONFIGURATION; | ||
14 | use crate::command::{Command, CommandLineError, GoalKind}; | 15 | use crate::command::{Command, CommandLineError, GoalKind}; |
15 | use crate::habit::{Bit, Count, Float, HabitWrapper, TrackEvent, ViewMode}; | 16 | use crate::habit::{Bit, Count, Float, HabitWrapper, TrackEvent, ViewMode}; |
16 | use crate::utils::{self, GRID_WIDTH, VIEW_HEIGHT, VIEW_WIDTH}; | 17 | use crate::utils::{self, VIEW_HEIGHT, VIEW_WIDTH}; |
17 | 18 | ||
18 | use crate::app::{App, Cursor, Message, MessageKind, StatusLine}; | 19 | use crate::app::{App, Cursor, Message, MessageKind, StatusLine}; |
19 | 20 | ||
@@ -105,15 +106,15 @@ impl App { | |||
105 | } | 106 | } |
106 | } | 107 | } |
107 | Absolute::Down => { | 108 | Absolute::Down => { |
108 | if self.focus + GRID_WIDTH < self.habits.len() - 1 { | 109 | if self.focus + CONFIGURATION.grid_size() < self.habits.len() - 1 { |
109 | self.focus += GRID_WIDTH; | 110 | self.focus += CONFIGURATION.grid_size(); |
110 | } else { | 111 | } else { |
111 | self.focus = self.habits.len() - 1; | 112 | self.focus = self.habits.len() - 1; |
112 | } | 113 | } |
113 | } | 114 | } |
114 | Absolute::Up => { | 115 | Absolute::Up => { |
115 | if self.focus as isize - GRID_WIDTH as isize >= 0 { | 116 | if self.focus as isize - CONFIGURATION.grid_size() as isize >= 0 { |
116 | self.focus -= GRID_WIDTH; | 117 | self.focus -= CONFIGURATION.grid_size(); |
117 | } else { | 118 | } else { |
118 | self.focus = 0; | 119 | self.focus = 0; |
119 | } | 120 | } |
@@ -152,10 +153,10 @@ impl App { | |||
152 | } | 153 | } |
153 | 154 | ||
154 | pub fn max_size(&self) -> Vec2 { | 155 | pub fn max_size(&self) -> Vec2 { |
155 | let width = GRID_WIDTH * VIEW_WIDTH; | 156 | let width = CONFIGURATION.grid_size() * VIEW_WIDTH; |
156 | let height = { | 157 | let height = { |
157 | if !self.habits.is_empty() { | 158 | if !self.habits.is_empty() { |
158 | (VIEW_HEIGHT as f64 * (self.habits.len() as f64 / GRID_WIDTH as f64).ceil()) | 159 | (VIEW_HEIGHT as f64 * (self.habits.len() as f64 / CONFIGURATION.grid_size() as f64).ceil()) |
159 | as usize | 160 | as usize |
160 | } else { | 161 | } else { |
161 | 0 | 162 | 0 |