mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 04:36:45 +01:00
fix passing numbers to edn view
This commit is contained in:
parent
07d90228d3
commit
f64a9731ce
4 changed files with 42 additions and 34 deletions
|
|
@ -21,21 +21,24 @@ pub struct Example(usize);
|
|||
impl EdnViewData<TuiOut> for &Example {
|
||||
fn get_content <'a> (&'a self, sym: EdnItem<&'a str>) -> RenderBox<'a, TuiOut> {
|
||||
Box::new(Thunk::new(move||match sym {
|
||||
EdnItem::Sym(":hello-world") => "Hello world!",
|
||||
EdnItem::Sym(":hello") => "Hello",
|
||||
EdnItem::Sym(":world") => "world",
|
||||
_ => ""
|
||||
EdnItem::Sym(":title") => Tui::bg(Color::Rgb(60,10,10), Push::y(1,
|
||||
Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len())))).boxed(),
|
||||
EdnItem::Sym(":code") => Tui::bg(Color::Rgb(10,60,10), Push::y(2,
|
||||
Align::n(format!("{}", EDN[self.0])))).boxed(),
|
||||
EdnItem::Sym(":hello-world") => "Hello world!".boxed(),
|
||||
EdnItem::Sym(":hello") => "Hello".boxed(),
|
||||
EdnItem::Sym(":world") => "world".boxed(),
|
||||
_ => "".boxed()
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl Content<TuiOut> for Example {
|
||||
fn content (&self) -> impl Render<TuiOut> {
|
||||
Bsp::a(Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len()))),
|
||||
Bsp::a(Push::y(2, Align::n(format!("{}", EDN[self.0]))),
|
||||
Tui::bg(Color::Rgb(10,20,30), EdnView::from_source(self, EDN[self.0]))
|
||||
)
|
||||
)
|
||||
let title = Tui::bg(Color::Rgb(60,10,10), Push::y(1, Align::n(format!("Example {}/{}:", self.0 + 1, EDN.len()))));
|
||||
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]));
|
||||
Bsp::s(title, Bsp::n(code, content))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
(fixed/xy 20 20 :hello-world)
|
||||
(fixed/xy 20 10 :hello-world)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue