mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
31 lines
730 B
Rust
31 lines
730 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<TuiOut> for Example {
|
|
fn content (&self) -> impl Render<TuiOut> {
|
|
EdnView::new(self, EDN).unwrap()
|
|
}
|
|
}
|
|
|
|
impl Handle<TuiIn> for Example {}
|