mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
WIP
This commit is contained in:
parent
2eaa5122ec
commit
6f7d3e5f0b
2 changed files with 13 additions and 1 deletions
12
src/app.rs
12
src/app.rs
|
@ -1,5 +1,6 @@
|
||||||
use color_eyre::eyre::Result;
|
use color_eyre::eyre::Result;
|
||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
|
use ratatui::prelude::Rect;
|
||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use tokio::sync::mpsc;
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
|
@ -113,6 +114,17 @@ impl App {
|
||||||
Action::Quit => self.should_quit = true,
|
Action::Quit => self.should_quit = true,
|
||||||
Action::Suspend => self.should_suspend = true,
|
Action::Suspend => self.should_suspend = true,
|
||||||
Action::Resume => self.should_suspend = false,
|
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 => {
|
Action::Render => {
|
||||||
tui.draw(|f| {
|
tui.draw(|f| {
|
||||||
for component in self.components.iter_mut() {
|
for component in self.components.iter_mut() {
|
||||||
|
|
|
@ -558,7 +558,7 @@ impl TaskReport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// now start trimming
|
// now start trimming
|
||||||
while (widths.iter().sum::<usize>() as u16) >= maximum_available_width - (self.labels.len()) as u16 {
|
while (widths.iter().sum::<usize>() 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();
|
let index = widths.iter().position(|i| i == widths.iter().max().unwrap_or(&0)).unwrap_or_default();
|
||||||
if widths[index] == 1 {
|
if widths[index] == 1 {
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue