mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 19:56:44 +01:00
edn -> dsl
This commit is contained in:
parent
d30eda33d1
commit
877b344765
35 changed files with 197 additions and 225 deletions
|
|
@ -1,6 +1,6 @@
|
|||
//! Aligns things to the container. Comes with caveats.
|
||||
//! ```
|
||||
//! use ::tek_tui::{*, tek_output::*};
|
||||
//! use ::tengri::{output::*, tui::*};
|
||||
//! let area: [u16;4] = [10, 10, 20, 20];
|
||||
//! fn test (area: [u16;4], item: &impl Content<TuiOut>, expected: [u16;4]) {
|
||||
//! assert_eq!(Content::layout(item, area), expected);
|
||||
|
|
@ -28,9 +28,12 @@
|
|||
//! test(area, &Align::w(two_by_four()), [10, 19, 4, 2]);
|
||||
//! ```
|
||||
use crate::*;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Default)] pub enum Alignment { #[default] Center, X, Y, NW, N, NE, E, SE, S, SW, W }
|
||||
pub struct Align<A>(Alignment, A);
|
||||
try_from_expr!(<'a, E>: Align<RenderBox<'a, E>>: |state, iter|
|
||||
|
||||
#[cfg(feature = "dsl")]
|
||||
try_from_expr!(<'a, E>: Align<RenderBox<'a, E>>: |state, iter|{
|
||||
if let Some(Token { value: Value::Key(key), .. }) = iter.peek() {
|
||||
match key {
|
||||
"align/c"|"align/x"|"align/y"|
|
||||
|
|
@ -56,7 +59,9 @@ try_from_expr!(<'a, E>: Align<RenderBox<'a, E>>: |state, iter|
|
|||
},
|
||||
_ => return None
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
impl<A> Align<A> {
|
||||
#[inline] pub fn c (a: A) -> Self { Self(Alignment::Center, a) }
|
||||
#[inline] pub fn x (a: A) -> Self { Self(Alignment::X, a) }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue