diff options
author | Akshay <[email protected]> | 2020-08-03 11:35:55 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-08-03 11:35:55 +0100 |
commit | fcaf919fd1e176e4b8dd6d5d21e25db7f68c32a8 (patch) | |
tree | b1fa143f95d5bbc48f4008641ce031cd7f5f4532 /src/views.rs | |
parent | 7e1dff439f1768fc463ddcfcd6ea58a7a1711056 (diff) |
use consts for dimensions
Diffstat (limited to 'src/views.rs')
-rw-r--r-- | src/views.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/views.rs b/src/views.rs index 7adf8c6..efd1391 100644 --- a/src/views.rs +++ b/src/views.rs | |||
@@ -8,6 +8,7 @@ use chrono::prelude::*; | |||
8 | use chrono::{Duration, Local, NaiveDate}; | 8 | use chrono::{Duration, Local, NaiveDate}; |
9 | 9 | ||
10 | use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; | 10 | use crate::habit::{Bit, Count, Habit, TrackEvent, ViewMode}; |
11 | use crate::utils::VIEW_WIDTH; | ||
11 | 12 | ||
12 | use crate::CONFIGURATION; | 13 | use crate::CONFIGURATION; |
13 | 14 | ||
@@ -38,7 +39,7 @@ where | |||
38 | 39 | ||
39 | let goal_reached_style = Style::from(CONFIGURATION.reached_color()); | 40 | let goal_reached_style = Style::from(CONFIGURATION.reached_color()); |
40 | let todo_style = Style::from(CONFIGURATION.todo_color()); | 41 | let todo_style = Style::from(CONFIGURATION.todo_color()); |
41 | let future_style = Style::from(CONFIGURATION.future_color()); | 42 | let future_style = Style::from(CONFIGURATION.inactive_color()); |
42 | 43 | ||
43 | let strikethrough = Style::from(Effect::Strikethrough); | 44 | let strikethrough = Style::from(Effect::Strikethrough); |
44 | 45 | ||
@@ -61,11 +62,7 @@ where | |||
61 | |p| { | 62 | |p| { |
62 | p.print( | 63 | p.print( |
63 | (0, 0), | 64 | (0, 0), |
64 | &format!( | 65 | &format!(" {:.width$} ", self.name(), width = VIEW_WIDTH - 6), |
65 | " {:.width$} ", | ||
66 | self.name(), | ||
67 | width = CONFIGURATION.view_width - 6 | ||
68 | ), | ||
69 | ); | 66 | ); |
70 | }, | 67 | }, |
71 | ); | 68 | ); |
@@ -80,7 +77,7 @@ where | |||
80 | let is_this_week = week.contains(&Local::now().naive_local().date()); | 77 | let is_this_week = week.contains(&Local::now().naive_local().date()); |
81 | let remaining = week.iter().map(|&i| self.remaining(i)).sum::<u32>(); | 78 | let remaining = week.iter().map(|&i| self.remaining(i)).sum::<u32>(); |
82 | let completions = weekly_goal - remaining; | 79 | let completions = weekly_goal - remaining; |
83 | let full = CONFIGURATION.view_width - 8; | 80 | let full = VIEW_WIDTH - 8; |
84 | let bars_to_fill = if weekly_goal > 0 { | 81 | let bars_to_fill = if weekly_goal > 0 { |
85 | (completions * full as u32) / weekly_goal | 82 | (completions * full as u32) / weekly_goal |
86 | } else { | 83 | } else { |
@@ -126,7 +123,7 @@ where | |||
126 | }); | 123 | }); |
127 | } else { | 124 | } else { |
128 | printer.with_style(future_style, |p| { | 125 | printer.with_style(future_style, |p| { |
129 | p.print(coords, &format!("{:^3}", CONFIGURATION.future_chr)); | 126 | p.print(coords, &format!("{:^3}", CONFIGURATION.look.future_chr)); |
130 | }); | 127 | }); |
131 | } | 128 | } |
132 | i += 1; | 129 | i += 1; |