summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRupert Rutledge <eosis2 [at] gmail.com>2020-05-09 17:10:20 +0100
committerRupert Rutledge <eosis2 [at] gmail.com>2020-05-09 17:10:20 +0100
commit0122bf351aefe55c568d24097b3f7eaa259ef041 (patch)
treefa147ed905f0794f1c47145ff44b19571ffea711
parentda17936d5c638f2d15004f475b64a417191c8f3c (diff)
Simplify logic in the header_parts function
-rw-r--r--src/display/components/total_bandwidth.rs14
1 files changed, 4 insertions, 10 deletions
diff --git a/src/display/components/total_bandwidth.rs b/src/display/components/total_bandwidth.rs
index 7c4bf44..c9a9676 100644
--- a/src/display/components/total_bandwidth.rs
+++ b/src/display/components/total_bandwidth.rs
@@ -86,16 +86,10 @@ impl<'a> HeaderDetails<'a> {
}
fn header_parts(&self, rect: Rect) -> Vec<Rect> {
- let number = {
- match rect.width {
- 0..=62 => 1,
- 63..=93 => 2,
- _ => 3,
- }
- };
-
- let constraints: Vec<Constraint> = (0..number)
- .map(|_| Constraint::Percentage(100 / number))
+ const MAX_BANDWIDTH_STRING_LENGTH: u16 = 31;
+ let number_of_columns = rect.width / MAX_BANDWIDTH_STRING_LENGTH;
+ let constraints: Vec<Constraint> = (0..number_of_columns)
+ .map(|_| Constraint::Percentage(100 / number_of_columns))
.collect();
::tui::layout::Layout::default()