diff --git a/src/app.rs b/src/app.rs index 5e02af0..4ff3b0a 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,5 +1,6 @@ use color_eyre::eyre::Result; use crossterm::event::KeyEvent; +use ratatui::prelude::Rect; use serde_derive::{Deserialize, Serialize}; use tokio::sync::mpsc; @@ -113,6 +114,17 @@ impl App { Action::Quit => self.should_quit = true, Action::Suspend => self.should_suspend = true, Action::Resume => self.should_suspend = false, + Action::Resize(w, h) => { + tui.resize(Rect::new(0, 0, w, h))?; + tui.draw(|f| { + for component in self.components.iter_mut() { + let r = component.draw(f, f.size()); + if let Err(e) = r { + action_tx.send(Action::Error(format!("Failed to draw: {:?}", e))).unwrap(); + } + } + })?; + }, Action::Render => { tui.draw(|f| { for component in self.components.iter_mut() { diff --git a/src/components/task_report.rs b/src/components/task_report.rs index 3bd453c..85b7b58 100644 --- a/src/components/task_report.rs +++ b/src/components/task_report.rs @@ -558,7 +558,7 @@ impl TaskReport { } } // now start trimming - while (widths.iter().sum::() as u16) >= maximum_available_width - (self.labels.len()) as u16 { + while (widths.iter().sum::() as u16) >= maximum_available_width.saturating_sub(self.labels.len() as u16) { let index = widths.iter().position(|i| i == widths.iter().max().unwrap_or(&0)).unwrap_or_default(); if widths[index] == 1 { break;