string formatting

This commit is contained in:
dal 2025-04-10 11:21:00 -06:00
parent 9202a31780
commit 3cd42527ec
No known key found for this signature in database
GPG Key ID: 16F4B0E1E9F61122
1 changed files with 14 additions and 4 deletions

View File

@ -106,13 +106,23 @@ fn render_messages(frame: &mut Frame, app: &AppState, area: Rect) {
.add_modifier(Modifier::BOLD),
);
let mut lines_for_msg = vec![prefix];
if let Some(c) = content {
lines_for_msg.push(Span::styled(c, Style::default().fg(Color::White)));
let lines: Vec<&str> = c.split('\n').collect();
for (i, line_content) in lines.iter().enumerate() {
let line_span = Span::styled(*line_content, Style::default().fg(Color::White));
if i == 0 {
message_lines.push(Line::from(vec![prefix.clone(), line_span]));
} else {
message_lines.push(Line::from(vec![
Span::raw(" "),
line_span,
]));
}
}
} else {
message_lines.push(Line::from(prefix));
}
message_lines.push(Line::from(lines_for_msg));
if !is_in_progress {
message_lines.push(Line::from(""));
}