Skip to content

Commit

Permalink
Merge branch 'main' into eliza/truncate-paths
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw authored Aug 4, 2021
2 parents 08b1ae3 + 1abf13d commit 66b0f00
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
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

0 comments on commit 66b0f00

Please sign in to comment.