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

Remove the extra space, and make the wide element fill the whole term… #350

Merged
merged 2 commits into from Jan 25, 2022
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
7 changes: 4 additions & 3 deletions src/draw_target.rs
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
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