From dd2394e1bece8056d51f2a8ec88f69ba528ee041 Mon Sep 17 00:00:00 2001 From: ahaoboy <504595380@qq.com> Date: Tue, 17 Sep 2024 15:02:50 +0800 Subject: [PATCH] fix fastfetch --- ansi2/src/lib.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ansi2/src/lib.rs b/ansi2/src/lib.rs index 6f87784..5a37e63 100644 --- a/ansi2/src/lib.rs +++ b/ansi2/src/lib.rs @@ -1,9 +1,9 @@ +pub mod css; pub mod html; pub mod lex; pub mod svg; pub mod text; pub mod theme; -pub mod css; use lex::{parse_ansi, AnsiColor, Token}; #[derive(Debug, Clone)] @@ -134,7 +134,7 @@ impl Canvas { cur_y = cur_y.saturating_sub(n as usize); cur_x = 0; } - Token::CursorHorizontalAbsolute(n) => cur_y = n as usize, + Token::CursorHorizontalAbsolute(n) => cur_x = (n - 1).max(0) as usize, Token::CursorPosition(x, y) => { cur_x = x as usize; cur_y = y as usize; @@ -240,4 +240,11 @@ mod test { let r = parse_ansi(s).unwrap(); println!("{:?}", r); } + + #[test] + fn test_fastfetch() { + let s = ""; + let r = parse_ansi(s).unwrap(); + println!("{:?}", r); + } }