pub struct DeltaDisplayFormatter {
mark_partial: bool,
}
impl DeltaDisplayFormatter {
#[must_use]
pub const fn new() -> Self {
Self { mark_partial: true }
}
#[must_use]
pub fn format_thinking(
&self,
content: &str,
prefix: &str,
colors: Colors,
terminal_mode: crate::json_parser::terminal::TerminalMode,
) -> String {
use crate::json_parser::terminal::TerminalMode;
match terminal_mode {
TerminalMode::None => format!("[{prefix}] Thinking: {content}\n"),
TerminalMode::Full | TerminalMode::Basic => {
format_thinking_with_colors(content, prefix, colors, self.mark_partial)
}
}
}
#[must_use]
pub fn format_tool_input(
&self,
content: &str,
prefix: &str,
colors: Colors,
terminal_mode: crate::json_parser::terminal::TerminalMode,
) -> String {
use crate::json_parser::terminal::TerminalMode;
match terminal_mode {
TerminalMode::Full => format_tool_input_full(content, prefix, colors, self.mark_partial),
TerminalMode::Basic | TerminalMode::None => String::new(),
}
}
}
fn format_thinking_with_colors(
content: &str,
prefix: &str,
colors: Colors,
mark_partial: bool,
) -> String {
if mark_partial {
format!(
"{}[{}]{} {}Thinking: {}{}{}\n",
colors.dim(),
prefix,
colors.reset(),
colors.dim(),
colors.cyan(),
content,
colors.reset()
)
} else {
format!(
"{}[{}]{} {}Thinking: {}{}{}\n",
colors.dim(),
prefix,
colors.reset(),
colors.cyan(),
colors.reset(),
content,
colors.reset()
)
}
}
fn format_tool_input_full(
content: &str,
prefix: &str,
colors: Colors,
mark_partial: bool,
) -> String {
if mark_partial {
format!(
"{}[{}]{} {} └─ {}{}{}\n",
colors.dim(),
prefix,
colors.reset(),
colors.dim(),
colors.reset(),
content,
colors.reset()
)
} else {
format!(
"{}[{}]{} {} └─ {}{}\n",
colors.dim(),
prefix,
colors.reset(),
colors.reset(),
content,
colors.reset()
)
}
}
impl Default for DeltaDisplayFormatter {
fn default() -> Self {
Self::new()
}
}