tek/edn/examples/edn02.rs
2025-01-05 16:51:26 +01:00

31 lines
722 B
Rust

use tek_tui::{*, tek_layout::{*, tek_engine::*}};
use tek_edn::*;
use std::sync::{Arc, RwLock};
const EDN: &'static str = include_str!("edn02.edn");
fn main () -> Usually<()> {
let state = Arc::new(RwLock::new(Example));
Tui::new().unwrap().run(&state)?;
Ok(())
}
pub struct Example;
impl EdnViewData<Tui> for &Example {
fn get_content <'a> (&'a self, sym: &'a str) -> RenderBox<'a, Tui> {
Box::new(Thunk::new(move||match sym {
":hello" => "Hello",
":world" => "world",
_ => ""
}))
}
}
impl Content<Tui> for Example {
fn content (&self) -> impl Render<Tui> {
EdnView::new(self, EDN).unwrap()
}
}
impl Handle<Tui> for Example {}