refactor(tui): introduce LogLine to wrap log formatting

This commit is contained in:
Paul Campbell 2024-08-31 13:33:45 +01:00
parent 97b685363a
commit 576eaaf990

View file

@ -1,5 +1,5 @@
use git_next_core::git::graph::Log;
// //
use git_next_core::git::graph::Log;
use ratatui::{ use ratatui::{
text::{Line, Text}, text::{Line, Text},
widgets::{Paragraph, Widget}, widgets::{Paragraph, Widget},
@ -23,10 +23,24 @@ impl<'a> Widget for CommitLog<'a> {
Paragraph::new(Text::from( Paragraph::new(Text::from(
self.log self.log
.iter() .iter()
.map(ToString::to_string) .map(LogLine::new)
.map(Line::from) .map(Line::from)
.collect::<Vec<_>>(), .collect::<Vec<_>>(),
)) ))
.render(area, buf); .render(area, buf);
} }
} }
struct LogLine {
raw: String,
}
impl LogLine {
fn new(raw: impl Into<String>) -> Self {
Self { raw: raw.into() }
}
}
impl From<LogLine> for Line<'_> {
fn from(value: LogLine) -> Self {
Line::from(value.raw)
}
}