From 851b61e0a987d693a63909035cc3c7183d61da83 Mon Sep 17 00:00:00 2001 From: Caleb Bassi Date: Mon, 13 Jan 2020 10:50:53 -0800 Subject: [PATCH] Temporarily fix table width bug --- src/widgets/disk.rs | 22 ++++++++++++++-------- src/widgets/proc.rs | 3 ++- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/widgets/disk.rs b/src/widgets/disk.rs index f6f5ed6..e8d5dae 100644 --- a/src/widgets/disk.rs +++ b/src/widgets/disk.rs @@ -130,14 +130,20 @@ impl Widget for DiskWidget<'_> { ) .block(block::new(self.colorscheme, &self.title)) .header_style(self.colorscheme.text.modifier(Modifier::BOLD)) - .widths(&[ - Constraint::Min(5), - Constraint::Min(5), - Constraint::Length(5), - Constraint::Length(8), - Constraint::Length(8), - Constraint::Length(8), - ]) + .widths(&if area.width > 55 { + vec![ + // Constraint::Min(5), + // Constraint::Min(5), + Constraint::Length(u16::max((area.width as i16 - 2 - 50) as u16, 5)), + Constraint::Length(u16::max((area.width as i16 - 2 - 50) as u16, 5)), + Constraint::Length(5), + Constraint::Length(8), + Constraint::Length(8), + Constraint::Length(8), + ] + } else { + vec![Constraint::Length(5), Constraint::Length(5)] + }) .column_spacing(1) .header_gap(0) .draw(area, buf); diff --git a/src/widgets/proc.rs b/src/widgets/proc.rs index 8148560..91f28d1 100644 --- a/src/widgets/proc.rs +++ b/src/widgets/proc.rs @@ -118,7 +118,8 @@ impl Widget for ProcWidget<'_> { .header_style(self.colorscheme.text.modifier(Modifier::BOLD)) .widths(&[ Constraint::Length(5), - Constraint::Min(5), + // Constraint::Min(5), + Constraint::Length(u16::max((area.width as i16 - 2 - 18) as u16, 5)), Constraint::Length(5), Constraint::Length(5), ])