mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
fix test suite
This commit is contained in:
parent
43ccfff24a
commit
acfaf757ec
4 changed files with 24 additions and 29 deletions
|
|
@ -19,35 +19,32 @@ const EDN: &'static [&'static str] = &[
|
|||
include_str!("edn12.edn"),
|
||||
include_str!("edn13.edn"),
|
||||
];
|
||||
|
||||
fn main () -> Usually<()> {
|
||||
let state = Arc::new(RwLock::new(Example(10, Measure::new())));
|
||||
Tui::new().unwrap().run(&state)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug)] pub struct Example(usize, Measure<TuiOut>);
|
||||
|
||||
edn_provide_content!(|self: Example|{
|
||||
":title" => Tui::bg(Color::Rgb(60,10,10), Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len())))).boxed(),
|
||||
":code" => Tui::bg(Color::Rgb(10,60,10), Push::y(2, Align::n(format!("{}", EDN[self.0])))).boxed(),
|
||||
":hello-world" => "Hello world!".boxed(),
|
||||
":hello" => Tui::bg(Color::Rgb(10, 100, 10), "Hello").boxed(),
|
||||
":world" => Tui::bg(Color::Rgb(100, 10, 10), "world").boxed(),
|
||||
});
|
||||
|
||||
impl Content<TuiOut> for Example {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
let title = Tui::bg(Color::Rgb(60,10,10),
|
||||
Push::y(1, Align::n(format!("Example {}/{} in {:?}", self.0 + 1, EDN.len(), &self.1.wh()))));
|
||||
let code = Tui::bg(Color::Rgb(10,60,10),
|
||||
Push::y(2, Align::n(format!("{}", EDN[self.0]))));
|
||||
let content = Tui::bg(Color::Rgb(10,10,60),
|
||||
EdnView::from_source(self, EDN[self.0]));
|
||||
self.1.of(Bsp::s(title, Bsp::n(""/*code*/, content)))
|
||||
edn_view!(TuiOut: |self: Example|{
|
||||
let title = Tui::bg(Color::Rgb(60,10,10),
|
||||
Push::y(1, Align::n(format!("Example {}/{} in {:?}", self.0 + 1, EDN.len(), &self.1.wh()))));
|
||||
let code = Tui::bg(Color::Rgb(10,60,10),
|
||||
Push::y(2, Align::n(format!("{}", EDN[self.0]))));
|
||||
let content = Tui::bg(Color::Rgb(10,10,60),
|
||||
EdnView::from_source(self, EDN[self.0]));
|
||||
self.1.of(Bsp::s(title, Bsp::n(""/*code*/, content)))
|
||||
};{
|
||||
bool {};
|
||||
u16 {};
|
||||
usize {};
|
||||
Box<dyn Render<TuiOut> + 'a> {
|
||||
":title" => Tui::bg(Color::Rgb(60,10,10), Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len())))).boxed(),
|
||||
":code" => Tui::bg(Color::Rgb(10,60,10), Push::y(2, Align::n(format!("{}", EDN[self.0])))).boxed(),
|
||||
":hello-world" => "Hello world!".boxed(),
|
||||
":hello" => Tui::bg(Color::Rgb(10, 100, 10), "Hello").boxed(),
|
||||
":world" => Tui::bg(Color::Rgb(100, 10, 10), "world").boxed()
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
impl Handle<TuiIn> for Example {
|
||||
fn handle (&mut self, input: &TuiIn) -> Perhaps<bool> {
|
||||
match input.event() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue