aboutsummaryrefslogtreecommitdiff
path: root/src/views.rs
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-07-12 10:09:51 +0100
committerAkshay <[email protected]>2020-07-12 10:09:51 +0100
commit6f572a1384cfa2aa7cc0c0412b762d03a55f3024 (patch)
tree004fe0421a5c7b1c5fd7751c6f13eb7997a74833 /src/views.rs
parentec875633e34614cfa656c4e0dbb35cddcca38d14 (diff)
improve spacing, line counting; add Week mode to enums
Diffstat (limited to 'src/views.rs')
-rw-r--r--src/views.rs12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/views.rs b/src/views.rs
index f5ba01b..9e4a844 100644
--- a/src/views.rs
+++ b/src/views.rs
@@ -75,7 +75,7 @@ where
75 let completions = weekly_goal - remaining; 75 let completions = weekly_goal - remaining;
76 let full = CONFIGURATION.view_width - 8; 76 let full = CONFIGURATION.view_width - 8;
77 let bars_to_fill = (completions * full as u32) / weekly_goal; 77 let bars_to_fill = (completions * full as u32) / weekly_goal;
78 let percentage = (completions as f64 * 100f64) / weekly_goal as f64; 78 let percentage = (completions as f64 * 100.) / weekly_goal as f64;
79 printer.with_style(future_style, |p| { 79 printer.with_style(future_style, |p| {
80 p.print((4, line_nr), &"―".repeat(full)); 80 p.print((4, line_nr), &"―".repeat(full));
81 }); 81 });
@@ -89,14 +89,15 @@ where
89 future_style 89 future_style
90 }, 90 },
91 |p| { 91 |p| {
92 p.print((0, line_nr), &format!("{:3.0}% ", percentage)); 92 p.print((0, line_nr), &format!("{:2.0}% ", percentage));
93 }, 93 },
94 ); 94 );
95 } 95 }
96 }; 96 };
97
97 let draw_day = |printer: &Printer| { 98 let draw_day = |printer: &Printer| {
98 let mut i = 1; 99 let mut i = 0;
99 while let Some(d) = NaiveDate::from_ymd_opt(year, month, i) { 100 while let Some(d) = NaiveDate::from_ymd_opt(year, month, i + 1) {
100 let day_style; 101 let day_style;
101 if self.reached_goal(d) { 102 if self.reached_goal(d) {
102 day_style = goal_reached_style; 103 day_style = goal_reached_style;
@@ -116,9 +117,10 @@ where
116 i += 1; 117 i += 1;
117 } 118 }
118 }; 119 };
120
119 match self.view_mode() { 121 match self.view_mode() {
120 ViewMode::Day => draw_day(printer), 122 ViewMode::Day => draw_day(printer),
121 ViewMode::Month => draw_month(printer), 123 ViewMode::Week => draw_month(printer),
122 _ => draw_day(printer), 124 _ => draw_day(printer),
123 }; 125 };
124 } 126 }