ops: fix Map::east/south with example

This commit is contained in:
🪞👃🪞 2025-04-25 19:01:02 +03:00
parent 2e9ba1b92d
commit 222e10239b
6 changed files with 19 additions and 9 deletions

View file

@ -62,9 +62,9 @@ where
get_item: impl Fn(A, usize)->B + Send + Sync
) -> Map<
E, A,
Push<E::Unit, Align<Fixed<E::Unit, Fill<B>>>>,
Push<E::Unit, Align<Fixed<E::Unit, B>>>,
I, F,
impl Fn(A, usize)->Push<E::Unit, Align<Fixed<E::Unit, Fill<B>>>> + Send + Sync
impl Fn(A, usize)->Push<E::Unit, Align<Fixed<E::Unit, B>>> + Send + Sync
> {
Map {
__: PhantomData,
@ -75,7 +75,7 @@ where
for i in 0..index {
push = push + size;
}
Push::x(push, Align::w(Fixed::x(size, Fill::y(get_item(item, index)))))
Push::x(push, Align::w(Fixed::x(size, get_item(item, index))))
}
}
}
@ -86,9 +86,9 @@ where
get_item: impl Fn(A, usize)->B + Send + Sync
) -> Map<
E, A,
Push<E::Unit, Fixed<E::Unit, Fill<B>>>,
Push<E::Unit, Align<Fixed<E::Unit, B>>>,
I, F,
impl Fn(A, usize)->Push<E::Unit, Fixed<E::Unit, Fill<B>>> + Send + Sync
impl Fn(A, usize)->Push<E::Unit, Align<Fixed<E::Unit, B>>> + Send + Sync
> where
E: Output,
B: Render<E>,
@ -104,7 +104,7 @@ where
for i in 0..index {
push = push + size;
}
Push::y(push, Fixed::y(size, Fill::x(get_item(item, index))))
Push::y(push, Align::n(Fixed::y(size, get_item(item, index))))
}
}
}

1
tui/examples/edn14.edn Normal file
View file

@ -0,0 +1 @@
:map-e

1
tui/examples/edn15.edn Normal file
View file

@ -0,0 +1 @@
(align/c :map-e)

1
tui/examples/edn16.edn Normal file
View file

@ -0,0 +1 @@
:map-s

1
tui/examples/edn17.edn Normal file
View file

@ -0,0 +1 @@
(align/c :map-s)

View file

@ -25,7 +25,11 @@ const EXAMPLES: &'static [&'static str] = &[
include_str!("edn10.edn"),
include_str!("edn11.edn"),
include_str!("edn12.edn"),
include_str!("edn13.edn"),
//include_str!("edn13.edn"),
include_str!("edn14.edn"),
include_str!("edn15.edn"),
include_str!("edn16.edn"),
include_str!("edn17.edn"),
];
handle!(TuiIn: |self: Example, input|{
@ -58,7 +62,7 @@ atom_command!(ExampleCommand: |app: Example| {
view!(TuiOut: |self: Example|{
let index = self.0 + 1;
let wh = self.1.wh();
let src = EXAMPLES[self.0];
let src = EXAMPLES.get(self.0).unwrap_or(&"");
let heading = format!("Example {}/{} in {:?}", index, EXAMPLES.len(), &wh);
let title = Tui::bg(Color::Rgb(60, 10, 10), Push::y(1, Align::n(heading)));
let code = Tui::bg(Color::Rgb(10, 60, 10), Push::y(2, Align::n(format!("{}", src))));
@ -69,7 +73,9 @@ view!(TuiOut: |self: Example|{
":code" => Tui::bg(Color::Rgb(10, 60, 10), Push::y(2, Align::n(format!("{}", EXAMPLES[self.0])))).boxed(),
":hello" => Tui::bg(Color::Rgb(10, 100, 10), "Hello").boxed(),
":world" => Tui::bg(Color::Rgb(100, 10, 10), "world").boxed(),
":hello-world" => "Hello world!".boxed()
":hello-world" => "Hello world!".boxed(),
":map-e" => Map::east(5u16, ||0..5u16, |n, i|format!("{n}")).boxed(),
":map-s" => Map::south(5u16, ||0..5u16, |n, i|format!("{n}")).boxed(),
});
expose! {