From 2df759885bfde575eec20ecb695a11916d68d78b Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Thu, 15 Mar 2018 22:09:35 +0100 Subject: [PATCH 1/3] Add writeln to print without breaking pbr --- src/pb.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/pb.rs b/src/pb.rs index 004ec6e9..27bdcf54 100644 --- a/src/pb.rs +++ b/src/pb.rs @@ -396,6 +396,13 @@ impl ProgressBar { self.last_refresh_time = SteadyTime::now(); } + /// Print a line above the progress bar + pub fn writeln(&mut self, s: &str) { + printfl!(self.handle, "\r\x1B[2K{}\n", s); + self.draw(); + } + + // finish_draw ensure that the progress bar is reached to its end, and do the // last drawing if needed. fn finish_draw(&mut self) { From 833bc0beb3a8a4ef55a1d70a27f62808ad25e421 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Thu, 15 Mar 2018 22:09:56 +0100 Subject: [PATCH 2/3] Make width public --- src/pb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pb.rs b/src/pb.rs index 27bdcf54..3a6baf20 100644 --- a/src/pb.rs +++ b/src/pb.rs @@ -462,7 +462,7 @@ impl ProgressBar { } /// Get terminal width, from configuration, terminal size, or default(80) - fn width(&mut self) -> usize { + pub fn width(&mut self) -> usize { if let Some(w) = self.width { w } else if let Some((Width(w), _)) = terminal_size() { From 3db27b473a801309646ea22216aab64c35b17cd0 Mon Sep 17 00:00:00 2001 From: kpcyrd Date: Fri, 16 Mar 2018 05:06:30 +0100 Subject: [PATCH 3/3] Make draw public --- src/pb.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pb.rs b/src/pb.rs index 3a6baf20..07bbc937 100644 --- a/src/pb.rs +++ b/src/pb.rs @@ -306,7 +306,7 @@ impl ProgressBar { self.add(1) } - fn draw(&mut self) { + pub fn draw(&mut self) { let now = SteadyTime::now(); if let Some(mrr) = self.max_refresh_rate { if now - self.last_refresh_time < mrr {