forked from kemitix/git-next
refactor(tui): introduce LogLine to wrap log formatting
This commit is contained in:
parent
97b685363a
commit
576eaaf990
1 changed files with 16 additions and 2 deletions
|
@ -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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue