mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
separate Input and Output impls
This commit is contained in:
parent
a6efde40f8
commit
0e821e098f
77 changed files with 465 additions and 454 deletions
|
|
@ -17,23 +17,27 @@ fn main () -> Usually<()> {
|
|||
pub struct Example(usize);
|
||||
|
||||
impl EdnViewData<Tui> for &Example {
|
||||
fn get_content <'a> (&'a self, sym: &'a str) -> RenderBox<'a, Tui> {
|
||||
fn get_content <'a> (&'a self, sym: EdnItem<&'a str>) -> RenderBox<'a, Tui> {
|
||||
Box::new(Thunk::new(move||match sym {
|
||||
":hello-world" => "Hello world!",
|
||||
":hello" => "Hello",
|
||||
":world" => "world",
|
||||
EdnItem::Sym(":hello-world") => "Hello world!",
|
||||
EdnItem::Sym(":hello") => "Hello",
|
||||
EdnItem::Sym(":world") => "world",
|
||||
_ => ""
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Content<Tui> for Example {
|
||||
fn content (&self) -> impl Render<Tui> {
|
||||
EdnView::new(self, EDN[self.0]).unwrap()
|
||||
impl Content<TuiOut> for Example {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
Bsp::a(
|
||||
&format!("{}", self.0),
|
||||
EdnView::new(self, EDN[self.0])
|
||||
.unwrap_or_else(|e|format!("Failed to render {}: {e}", self.0))
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl Handle<Tui> for Example {
|
||||
impl Handle<TuiIn> for Example {
|
||||
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
||||
match input.event() {
|
||||
kpat!(Right) => self.0 = (self.0 + 1) % EDN.len(),
|
||||
|
|
@ -22,10 +22,10 @@ impl EdnViewData<Tui> for &Example {
|
|||
}
|
||||
}
|
||||
|
||||
impl Content<Tui> for Example {
|
||||
fn content (&self) -> impl Render<Tui> {
|
||||
impl Content<TuiOut> for Example {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
EdnView::new(self, EDN).unwrap()
|
||||
}
|
||||
}
|
||||
|
||||
impl Handle<Tui> for Example {}
|
||||
impl Handle<TuiIn> for Example {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue