use std::cell::RefCell;
use std::rc::Rc;
use crate::tui::Component;
use crate::tui::Container;
#[derive(Clone)]
pub struct RefContainer {
pub inner: Rc<RefCell<Container>>,
}
impl RefContainer {
pub fn new() -> Self {
Self {
inner: Rc::new(RefCell::new(Container::new())),
}
}
pub fn new_rc() -> Rc<RefCell<Container>> {
Rc::new(RefCell::new(Container::new()))
}
}
impl Default for RefContainer {
fn default() -> Self {
Self::new()
}
}
impl Component for RefContainer {
fn render(&self, width: usize) -> Vec<String> {
self.inner.borrow().render(width)
}
fn invalidate(&mut self) {
self.inner.borrow_mut().invalidate();
}
}