mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-09-18 05:16:44 +02:00
separate mod text; perf: don't branch with Tui
This commit is contained in:
parent
b318d498e5
commit
c9a89eeb1d
9 changed files with 271 additions and 267 deletions
|
|
@ -454,5 +454,5 @@ impl<'a, S: Screen, T: Draw<S>> LayoutPull<'a, S> for T {}
|
|||
impl<'a, S: Screen, T: Draw<S>> LayoutPad<'a, S> for T {}
|
||||
|
||||
pub fn check_layout <'a> (t: impl Draw<Tui>) -> Drawn<u16> {
|
||||
Tui::Layout(XYWH(1u16, 1, 80, 25)).size(None, t)
|
||||
Tui(XYWH(1u16, 1, 80, 25), None).size(None, t)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -226,7 +226,10 @@ pub fn bar_areas <'a, S: Screen> (
|
|||
to.size(XYWH(x0 + w0 - n, y0, n, h0), a)?,
|
||||
to.size(XYWH(x0, y0, w0 - n, h0), b)?,
|
||||
),
|
||||
_ => todo!()
|
||||
Split::Above | Split::Below => (
|
||||
to.size(XYWH(x0, y0, w0, h0), a)?,
|
||||
to.size(XYWH(x0, y0, w0, h0), b)?,
|
||||
),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +241,7 @@ pub struct Pair<A, B>(Split, A, B);
|
|||
/// use ::tengri::*;
|
||||
/// use Split::*;
|
||||
/// fn size_of <'a, A: Draw<Tui>, B: Draw<Tui>> (stack: &Pair<Tui, A, B>) -> Drawn<S::Unit> {
|
||||
/// Tui::Layout(XYWH(0, 0, 80, 25)).size(None, stack)
|
||||
/// Tui(XYWH(0, 0, 80, 25), None).size(None, stack)
|
||||
/// }
|
||||
/// assert_eq!(size_of(&split(East, "foo", "bar"))?, Some(XYWH(0, 0, 6, 1)));
|
||||
/// assert_eq!(size_of(&split(South, "foo", "bar"))?, Some(XYWH(0, 0, 3, 2)));
|
||||
|
|
@ -293,11 +296,11 @@ fn draw_stacks <'a, S: Screen> (
|
|||
/// ```
|
||||
/// # use ::tengri::*; fn test_stack_areas () -> Usually<()> {
|
||||
/// let area = XYWH(0u16, 0, 80, 25);
|
||||
/// assert_eq!(stack_areas(&Split::East, &mut Tui::Layout(area), &"foo", &"bar")?, (
|
||||
/// assert_eq!(stack_areas(&Split::East, &mut Tui(area, None), &"foo", &"bar")?, (
|
||||
/// Some(XYWH(0u16, 0, 3, 1)),
|
||||
/// Some(XYWH(3u16, 0, 3, 1)),
|
||||
/// ));
|
||||
/// assert_eq!(stack_areas(&Split::South, &mut Tui::Layout(area), &"foo", &"bar")?, (
|
||||
/// assert_eq!(stack_areas(&Split::South, &mut Tui(area, None), &"foo", &"bar")?, (
|
||||
/// Some(XYWH(0u16, 0, 3, 1)),
|
||||
/// Some(XYWH(0u16, 1, 3, 1)),
|
||||
/// ));
|
||||
|
|
@ -522,7 +525,7 @@ pub const fn below <'a, S: Screen, A: Draw<S>, B: Draw<S>> (a: A, b: B) -> impl
|
|||
}
|
||||
|
||||
#[cfg(test)] #[test] fn test_align () -> Usually<()> {
|
||||
let mut screen = Tui::Layout(XYWH(0, 0, 80, 25));
|
||||
let mut screen = Tui(XYWH(0, 0, 80, 25), None);
|
||||
assert_eq!("FOOBAR\nKILROY".draw(&mut screen)?, Some(XYWH(0, 0, 6, 2)));
|
||||
assert_eq!("FOOBAR\nKILROY".align_nw().draw(&mut screen)?, Some(XYWH(0, 0, 6, 2)));
|
||||
assert_eq!("FOOBAR\nKILROY".align_n().draw(&mut screen)?, Some(XYWH(37, 0, 6, 2)));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue