Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(console): stop truncating task fields column #82

Merged
merged 1 commit into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions console/src/view/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,4 +161,8 @@ impl Width {
pub(crate) fn constraint(&self) -> layout::Constraint {
layout::Constraint::Length(self.curr)
}

pub(crate) fn chars(&self) -> u16 {
self.curr
}
}
27 changes: 21 additions & 6 deletions console/src/view/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl List {
// there's room for the unit!)
const DUR_PRECISION: usize = 4;
const POLLS_LEN: usize = 5;
const KIND_LEN: u16 = 4;

self.sorted_tasks.extend(state.take_new_tasks());
self.sort_by.sort(now, &mut self.sorted_tasks);
Expand Down Expand Up @@ -162,15 +163,29 @@ impl List {
} else {
Table::new(rows.rev())
};

// How many characters wide are the fixed-length non-field columns?
let fixed_col_width = id_width.chars()
+ KIND_LEN
+ DUR_LEN as u16
+ DUR_LEN as u16
+ DUR_LEN as u16
+ POLLS_LEN as u16
+ target_width.chars();
// Fill all remaining characters in the frame with the task's fields.
// TODO(eliza): there's gotta be a nicer way to do this in `tui`...what
// we want is really just a constraint that says "always use all the
// characters remaining".
let fields_width = frame.size().width - fixed_col_width;
let widths = &[
id_width.constraint(),
layout::Constraint::Length(4),
layout::Constraint::Min(DUR_LEN as u16),
layout::Constraint::Min(DUR_LEN as u16),
layout::Constraint::Min(DUR_LEN as u16),
layout::Constraint::Min(POLLS_LEN as u16),
layout::Constraint::Length(KIND_LEN),
layout::Constraint::Length(DUR_LEN as u16),
layout::Constraint::Length(DUR_LEN as u16),
layout::Constraint::Length(DUR_LEN as u16),
layout::Constraint::Length(POLLS_LEN as u16),
target_width.constraint(),
layout::Constraint::Min(10),
layout::Constraint::Min(fields_width),
];
let t = t
.header(header)
Expand Down