mirror of
https://github.com/TECHNOFAB11/pay-respects.git
synced 2025-12-11 22:10:09 +01:00
fix: clear console line
This commit is contained in:
parent
005a3b6661
commit
10d20338e5
1 changed files with 9 additions and 2 deletions
|
|
@ -21,6 +21,13 @@ fn fill(str: &str) -> Option<String> {
|
|||
}
|
||||
}
|
||||
|
||||
fn clear_format(str: &str) -> String {
|
||||
let width = termwidth();
|
||||
let whitespace = " ".repeat(width);
|
||||
let filled = textwrap_fill(str, width);
|
||||
format!("\r{}\r{}", whitespace, filled)
|
||||
}
|
||||
|
||||
use colored::Colorize;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
|
|
@ -73,7 +80,7 @@ impl Buffer {
|
|||
let filled = fill(&buffered);
|
||||
if let Some(filled) = filled {
|
||||
self.buf.clear();
|
||||
let formatted = format!("\r{}", filled);
|
||||
let formatted = clear_format(&filled);
|
||||
eprint!("{}", formatted);
|
||||
self.buf
|
||||
.push(formatted.split_once("\n").unwrap().1.to_string());
|
||||
|
|
@ -149,7 +156,7 @@ impl Buffer {
|
|||
let filled = fill(&buffered);
|
||||
if let Some(filled) = filled {
|
||||
self.buf.clear();
|
||||
let formatted = format!("\r{}", filled);
|
||||
let formatted = clear_format(&filled);
|
||||
eprint!("{}", formatted);
|
||||
self.buf
|
||||
.push(formatted.split_once("\n").unwrap().1.to_string());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue