mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 17:57:19 +02:00
Fix spacing for all columns
This commit is contained in:
parent
39091231b0
commit
dac571f7e7
1 changed files with 13 additions and 8 deletions
21
src/app.rs
21
src/app.rs
|
@ -434,9 +434,9 @@ impl TTApp {
|
|||
vertical: 0, horizontal: 0,
|
||||
}));
|
||||
|
||||
let maximum_column_width = area.width;
|
||||
|
||||
let (contexts, headers) = self.get_all_contexts();
|
||||
|
||||
let maximum_column_width = area.width - 2;
|
||||
let widths = self.calculate_widths(&contexts, &headers, maximum_column_width);
|
||||
|
||||
let selected = self.context_table_state.selected().unwrap_or_default();
|
||||
|
@ -566,7 +566,7 @@ impl TTApp {
|
|||
|
||||
for row in tasks.iter() {
|
||||
for (i, cell) in row.iter().enumerate() {
|
||||
widths[i] = std::cmp::max(cell.len() + 2, widths[i]);
|
||||
widths[i] = std::cmp::max(cell.len(), widths[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,7 +579,7 @@ impl TTApp {
|
|||
}
|
||||
|
||||
// now start trimming
|
||||
while (widths.iter().sum::<usize>() as u16) >= maximum_column_width - 5 {
|
||||
while (widths.iter().sum::<usize>() as u16) >= maximum_column_width - (headers.len()) as u16 {
|
||||
let index = widths.iter().position(|i| i == widths.iter().max().unwrap()).unwrap();
|
||||
if widths[index] == 1 {
|
||||
break
|
||||
|
@ -587,6 +587,13 @@ impl TTApp {
|
|||
widths[index] -= 1;
|
||||
}
|
||||
|
||||
for (i, header) in headers.iter().enumerate() {
|
||||
if header == "ID" {
|
||||
// always give ID a couple of extra for indicator
|
||||
widths[i] += 2;
|
||||
break
|
||||
}
|
||||
}
|
||||
return widths
|
||||
}
|
||||
|
||||
|
@ -612,14 +619,12 @@ impl TTApp {
|
|||
return;
|
||||
}
|
||||
|
||||
let maximum_column_width = rect.width;
|
||||
let maximum_column_width = rect.width - 2;
|
||||
let widths = self.calculate_widths(&tasks, &headers, maximum_column_width);
|
||||
|
||||
for (i, header) in headers.iter().enumerate() {
|
||||
if header == "Description" || header == "Definition" {
|
||||
if widths[i] > headers.iter().len() {
|
||||
self.task_report_table.description_width = widths[i] - 1;
|
||||
}
|
||||
self.task_report_table.description_width = widths[i] - 1;
|
||||
break
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue