more built-in centering

This commit is contained in:
🪞👃🪞 2025-01-01 17:43:48 +01:00
parent 8454b95df8
commit a6a4eb80fd
5 changed files with 33 additions and 17 deletions

View file

@ -20,7 +20,7 @@ impl Direction {
Self::East => Self::South,
}
}
/// Return next direction counterclockwise
/// Return next direction counterclockwise01.
pub fn ccw (&self) -> Self {
match self {
Self::North => Self::West,

View file

@ -14,12 +14,18 @@ pub(crate) use std::marker::PhantomData;
#[cfg(test)] #[test] fn test_layout () -> Usually<()> {
use crate::tui::Tui;
let area: [u16;4] = [10, 10, 20, 20];
let unit = ();
// should be independent over E, isn't
assert_eq!(Content::<Tui>::layout(&unit, area), [15, 15, 0, 0]);
assert_eq!(Fill::<Tui, _>::x(unit).layout(area), [10, 15, 20, 0]);
assert_eq!(Fill::<Tui, _>::y(unit).layout(area), [15, 10, 0, 20]);
assert_eq!(Content::<Tui>::layout(&unit, area), [20, 20, 0, 0]);
assert_eq!(Fill::<Tui, _>::x(unit).layout(area), [10, 20, 20, 0]);
assert_eq!(Fill::<Tui, _>::y(unit).layout(area), [20, 10, 0, 20]);
assert_eq!(Fill::<Tui, _>::xy(unit).layout(area), area);
assert_eq!(Align::<Tui, _>::c(unit).layout(area), [20, 20, 0, 0]);
assert_eq!(Align::<Tui, _>::c(" ").layout(area), [20, 20, 0, 0]);
Ok(())
}