Skip to content

Commit

Permalink
Make lines fill the whole terminal width (#350)
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaSd authored Jan 25, 2022
1 parent 98d1cee commit af3bd31
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/draw_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,10 @@ impl ProgressDrawState {
} else {
// Don't append a '\n' if this is the last line
term.write_str(line)?;
// Also append a ' ' to keep the original chars count
// This is important if the line was meant to fill the entire width
term.write_str(" ")?;
// Keep the cursor on the right terminal side
// So that next user writes/prints will happen on the next line
let line_width = console::measure_text_width(line);
term.move_cursor_right(usize::from(term.size().1) - line_width)?;
}
}
Ok(())
Expand Down
1 change: 1 addition & 0 deletions src/style.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ impl<'a> WideElement<'a> {
buf: &mut String,
) -> String {
let left = state.width().saturating_sub(measure_text_width(&cur));
let left = left + 1; // Add 1 to cover the whole terminal width
match self {
Self::Bar { alt_style } => cur.replace(
"\x00",
Expand Down

0 comments on commit af3bd31

Please sign in to comment.