the wild Layout trait appears

This commit is contained in:
🪞👃🪞 2024-12-31 00:38:47 +01:00
parent 7c652135ad
commit d37bd3e0c5
7 changed files with 576 additions and 595 deletions

View file

@ -46,13 +46,13 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
fn area_mut (&mut self) -> &mut [u16;4] {
&mut self.0
}
fn render_in (&mut self, _: [u16;4], _: &dyn Render<TestEngine>) -> Usually<()> {
fn render_in (&mut self, _: [u16;4], _: &impl Render<TestEngine>) -> Usually<()> {
Ok(())
}
}
impl Render<TestEngine> for String {
fn min_size (&self, _: [u16;2]) -> Perhaps<[u16;2]> {
Ok(Some([self.len() as u16, 1]))
fn render (&self, to: &mut TestOutput) {
to.area_mut().set_w(self.len() as u16);
}
}
Ok(())
@ -62,9 +62,9 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
use crate::tui::*;
use std::sync::{Arc, RwLock};
struct TestComponent(String);
impl Content<Tui> for TestComponent {
fn content (&self) -> Option<impl Render<Tui>> {
Some(&self.0)
impl Layout<Tui> for TestComponent {
fn layout (&self) -> Option<impl Render<Tui>> {
Some(self.0.as_str())
}
}
impl Handle<Tui> for TestComponent {