Make buffers fill from the bottom, and render each paragraph individually
The goal of rendering paragraph individually is to eventually avoid redrawing everything every time there is a change
This commit is contained in:
@ -39,20 +39,23 @@ impl Buffer for LogBuffer {
|
||||
"ratatrix".to_owned()
|
||||
}
|
||||
|
||||
fn content(&self) -> Text {
|
||||
fn content(&self) -> Vec<Text> {
|
||||
use ansi_to_tui::IntoText;
|
||||
let lines = self
|
||||
.lines
|
||||
.read()
|
||||
.expect("LogBuffer could not get log's RwLock as it is poisoned");
|
||||
let (slice1, slice2) = lines.as_slices();
|
||||
let text = if slice1.is_empty() {
|
||||
slice2.join("\n")
|
||||
} else if slice2.is_empty() {
|
||||
slice1.join("\n")
|
||||
} else {
|
||||
format!("{}\n{}", slice1.join("\n"), slice2.join("\n"))
|
||||
};
|
||||
use ansi_to_tui::IntoText;
|
||||
text.clone().into_text().unwrap_or_else(|_| text.into())
|
||||
slice1
|
||||
.into_iter()
|
||||
.chain(slice2.into_iter())
|
||||
.cloned()
|
||||
.map(|line| {
|
||||
line.into_text().unwrap_or_else(|e| {
|
||||
tracing::error!("Could not convert line from ANSI codes to ratatui: {}", e);
|
||||
Text::raw(line)
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user