From 683715cd7af77d87a2ae3834360bb6f7a4388bd0 Mon Sep 17 00:00:00 2001 From: asepharyana Date: Wed, 15 Jul 2026 05:28:31 +0700 Subject: [PATCH] feat(view): Tambah parameter dim dan pewarnaan baris diff di markdown renderer Tambahkan helper apply_dim dan diff_line_style, ubah signature render_markdown untuk menerima flag dim, serta deteksi fence bahasa diff sehingga baris +/-/@@ tetap berwarna meskipun pesan sedang dirender dim (tampilan tool-output). --- src/view/markdown.rs | 146 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 122 insertions(+), 24 deletions(-) diff --git a/src/view/markdown.rs b/src/view/markdown.rs index 1d5a0c2..69062ac 100644 --- a/src/view/markdown.rs +++ b/src/view/markdown.rs @@ -19,21 +19,54 @@ use ratatui::style::{Modifier, Style}; use ratatui::text::Span; use super::theme::Theme; +/// Apply the "tool output" dim/italic style, or pass `style` through +/// unchanged, depending on `dim`. +fn apply_dim(style: Style, dim: bool) -> Style { + if dim { + Style::default().fg(Theme::TEXT_DIM).add_modifier(Modifier::ITALIC) + } else { + style + } +} + +/// Classify a single line inside a ` ```diff ` fenced block by its unified-diff +/// prefix, returning the color it should always render with (even when the +/// surrounding tool output is dimmed) — or `None` for context lines and the +/// `+++`/`---` file-header lines, which use the normal code-block color. +fn diff_line_style(line: &str) -> Option