mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 03:36:41 +01:00
26 lines
666 B
Rust
26 lines
666 B
Rust
use tek_edn::{*, tek_layout::{*, tek_engine::{*, tui::{*, TuiRun}}}};
|
|
use std::sync::{Arc, RwLock};
|
|
|
|
const EDN: &'static str = include_str!("edn01.edn");
|
|
|
|
fn main () -> Usually<()> {
|
|
let state = Arc::new(RwLock::new(Example));
|
|
Tui::new().unwrap().run(&state)?;
|
|
Ok(())
|
|
}
|
|
|
|
pub struct Example;
|
|
|
|
impl EdnLayout<Tui> for &Example {
|
|
fn get_content <'a> (&'a self, sym: &'a str) -> RenderBox<'a, Tui> {
|
|
Box::new(Thunk::new(move||if sym == ":hello" { "Hello world!" } else { "" }))
|
|
}
|
|
}
|
|
|
|
impl Content<Tui> for Example {
|
|
fn content (&self) -> impl Render<Tui> {
|
|
EdnView::new(self, EDN).unwrap()
|
|
}
|
|
}
|
|
|
|
impl Handle<Tui> for Example {}
|