Skip to content

Commit

Permalink
feat: add indication for multibar in pb
Browse files Browse the repository at this point in the history
  • Loading branch information
a8m committed Oct 28, 2016
1 parent f8144c7 commit f642e8f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/multi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ impl<T: Write> MultiBar<T> {
chan: self.chan.0.clone(),
},
total);
p.is_multibar = true;
p.add(0);
p
}
Expand Down
7 changes: 7 additions & 0 deletions src/pb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ pub struct ProgressBar<T: Write> {
last_refresh_time: SteadyTime,
max_refresh_rate: Option<time::Duration>,
pub is_finish: bool,
pub is_multibar: bool,
pub show_bar: bool,
pub show_speed: bool,
pub show_percent: bool,
Expand Down Expand Up @@ -114,6 +115,7 @@ impl<T: Write> ProgressBar<T> {
start_time: SteadyTime::now(),
units: Units::Default,
is_finish: false,
is_multibar: false,
show_bar: true,
show_speed: true,
show_percent: true,
Expand Down Expand Up @@ -428,6 +430,11 @@ impl<T: Write> ProgressBar<T> {
/// If the ProgressBar is part of MultiBar instance, you should use
/// `finish_print` to print message.
pub fn finish_println(&mut self, s: &str) {
// `finish_println` does not allow in MultiBar mode, because printing
// new line will break the multiBar output.
if self.is_multibar {
return self.finish_print(s);
}
self.finish_draw();
printfl!(self.handle, "\n{}", s);
}
Expand Down

0 comments on commit f642e8f

Please sign in to comment.