diff --git a/src/main.rs b/src/main.rs index d813f72..4ae6a74 100644 --- a/src/main.rs +++ b/src/main.rs @@ -188,9 +188,8 @@ async fn main() -> Result<(), Box> { } }; - // print the response - status.print("\n"); // reset cursor after progress output - status.print("\n"); // newline for readability + // print the response after clearing the status line + status.clear_line(); personality.speak(&text); status.print("\n"); // I really like readability diff --git a/src/status.rs b/src/status.rs index d2bc64a..ff7714f 100644 --- a/src/status.rs +++ b/src/status.rs @@ -9,6 +9,14 @@ impl Status { Self { silent: true } } + /// Clear a partially printed line that has not printed a final newline character + pub fn clear_line(&self) { + for _ in 0..100 { + self.print("\u{8}"); + self.print("\r"); // just to be sure + } + } + /// Print text to standard error pub fn print(&self, text: &str) { if self.silent {