From 390f4b5f7a617c690d75779fe0f8bf54a1038808 Mon Sep 17 00:00:00 2001 From: yggverse Date: Sun, 8 Dec 2024 11:14:46 +0200 Subject: [PATCH] update condition --- .../page/content/text/gemini/reader/ansi.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/browser/window/tab/item/page/content/text/gemini/reader/ansi.rs b/src/app/browser/window/tab/item/page/content/text/gemini/reader/ansi.rs index 5f5df5e5..803ec0e3 100644 --- a/src/app/browser/window/tab/item/page/content/text/gemini/reader/ansi.rs +++ b/src/app/browser/window/tab/item/page/content/text/gemini/reader/ansi.rs @@ -12,14 +12,15 @@ pub fn format(source_code: &str) -> Vec<(TextTag, String)> { let mut tag = Tag::new(); for ref entity in source_code.ansi_parse() { - if let Output::Escape(AnsiSequence::SetGraphicsMode(colors)) = entity { - if colors.len() == 1 { - } else if colors[0] == 38 { - tag.text_tag - .set_foreground_rgba(rgba::default(*colors.last().unwrap()).as_ref()); - } else { - tag.text_tag - .set_background_rgba(rgba::default(*colors.last().unwrap()).as_ref()); + if let Output::Escape(AnsiSequence::SetGraphicsMode(color)) = entity { + if color.len() > 1 { + if color[0] == 38 { + tag.text_tag + .set_foreground_rgba(rgba::default(*color.last().unwrap()).as_ref()); + } else { + tag.text_tag + .set_background_rgba(rgba::default(*color.last().unwrap()).as_ref()); + } } } if let Output::TextBlock(text) = entity {