use std::cell::RefCell;
use crate::tui::Component;
pub struct LinesComponent {
pub lines: RefCell<Vec<String>>,
}
impl LinesComponent {
pub fn new() -> Self {
Self {
lines: RefCell::new(Vec::new()),
}
}
pub fn set_lines(&self, new_lines: Vec<String>) {
*self.lines.borrow_mut() = new_lines;
}
pub fn push(&self, line: String) {
self.lines.borrow_mut().push(line);
}
pub fn extend(&self, lines: impl IntoIterator<Item = String>) {
self.lines.borrow_mut().extend(lines);
}
pub fn clear(&self) {
self.lines.borrow_mut().clear();
}
}
impl Default for LinesComponent {
fn default() -> Self {
Self::new()
}
}
impl Component for LinesComponent {
fn render(&self, _width: usize) -> Vec<String> {
self.lines.borrow().clone()
}
fn invalidate(&mut self) {
}
}