From 9e59bc187ccf4f5200bf4717e9a8c8f8b8a6e819 Mon Sep 17 00:00:00 2001 From: pythops Date: Wed, 22 May 2024 23:40:14 +0200 Subject: [PATCH] batter layout with Fill instead of Length constraint --- src/board.rs | 2 +- src/fan.rs | 2 +- src/power.rs | 27 +++++++++++++-------------- src/system.rs | 2 +- src/tracing.rs | 1 + 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/board.rs b/src/board.rs index 871cea8..ed39bba 100644 --- a/src/board.rs +++ b/src/board.rs @@ -80,7 +80,7 @@ impl Board { ]), ]; - let widths = [Constraint::Length(6), Constraint::Length(30)]; + let widths = [Constraint::Length(6), Constraint::Fill(1)]; let board = Table::new(rows, widths).block( Block::default() diff --git a/src/fan.rs b/src/fan.rs index 9054630..45d65a2 100644 --- a/src/fan.rs +++ b/src/fan.rs @@ -185,7 +185,7 @@ impl Fan { }, ])]; - let widths = [Constraint::Length(10), Constraint::Length(10)]; + let widths = [Constraint::Length(10), Constraint::Fill(1)]; let fan = Table::new(rows, widths) .header(Row::new(vec!["Profile", "RPM"]).style(Style::new().bold())) diff --git a/src/power.rs b/src/power.rs index 155e9ed..b5b4ee7 100644 --- a/src/power.rs +++ b/src/power.rs @@ -267,21 +267,20 @@ impl Power { }; // nvpmodel - - let nvpmodel = Table::new( - [Row::new(vec![ - Cell::new("Mode").style(Style::default().bold()), - Cell::new(match &self.nvpmode { - Some(nvpmode) => match &nvpmode.mode { - Some(mode) => format!("{}W", &mode.name), - None => " - ".to_string(), - }, + let rows = [Row::new(vec![ + Cell::new("Mode").style(Style::default().bold()), + Cell::new(match &self.nvpmode { + Some(nvpmode) => match &nvpmode.mode { + Some(mode) => format!("{}W", &mode.name), None => " - ".to_string(), - }), - ])], - [Constraint::Length(16), Constraint::Length(6)], - ) - .block(Block::default()); + }, + None => " - ".to_string(), + }), + ])]; + + let widths = [Constraint::Length(16), Constraint::Length(7)]; + + let nvpmodel = Table::new(rows, widths).block(Block::default()); // Power consumption let rows: Vec = self diff --git a/src/system.rs b/src/system.rs index 8994d3f..271107a 100644 --- a/src/system.rs +++ b/src/system.rs @@ -157,7 +157,7 @@ impl System { ]), ]; - let widths = [Constraint::Length(10), Constraint::Length(30)]; + let widths = [Constraint::Length(10), Constraint::Fill(1)]; let system = Table::new(rows, widths).block( Block::default() diff --git a/src/tracing.rs b/src/tracing.rs index 5d94552..639284e 100644 --- a/src/tracing.rs +++ b/src/tracing.rs @@ -19,6 +19,7 @@ impl Tracing { let log_file = OpenOptions::new() .create(true) + .truncate(true) .write(true) .open(log_file_path)?;