diff --git a/src/ansiiescape.rs b/src/ansiiescape.rs index c5bcafb..02a29a6 100644 --- a/src/ansiiescape.rs +++ b/src/ansiiescape.rs @@ -1,11 +1,15 @@ fn escape(s: String) -> String { - format!("\x1b[{}m", s) + format!("\x1b[{}", s) } pub fn reset() -> String { - escape("0".to_string()) + escape("0m".to_string()) } pub fn color(r: u8, g: u8, b: u8) -> String { - escape(format!("38;2;{};{};{}", r, g, b)) + escape(format!("38;2;{};{};{}m", r, g, b)) +} + +pub fn cursor_up(lines: u32) -> String { + escape(format!("{}A", lines)) } diff --git a/src/main.rs b/src/main.rs index 1d4f7b5..b0b1088 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,7 @@ use std::thread::sleep; use std::time; use fuedra_schwitzt::cpuusagebuffer::CpuUsageBuffer; +use fuedra_schwitzt::ansiiescape::cursor_up; fn main() { @@ -17,7 +18,7 @@ fn main() { buffer.push(); // Reset paint area - print!("\x1b[{}A", buffer.cpu_num()); + print!("{}", cursor_up(buffer.cpu_num().try_into().unwrap())); // Print buffer print!("{}", buffer.braille());