0.7.1: log unresolved content in all cases

This commit is contained in:
🪞👃🪞 2025-04-13 21:49:18 +03:00
parent f33f331a48
commit 34295570a2
7 changed files with 70 additions and 39 deletions

10
Cargo.lock generated
View file

@ -934,7 +934,7 @@ dependencies = [
[[package]] [[package]]
name = "tengri" name = "tengri"
version = "0.7.0" version = "0.7.1"
dependencies = [ dependencies = [
"tengri_dsl", "tengri_dsl",
"tengri_input", "tengri_input",
@ -944,7 +944,7 @@ dependencies = [
[[package]] [[package]]
name = "tengri_dsl" name = "tengri_dsl"
version = "0.7.0" version = "0.7.1"
dependencies = [ dependencies = [
"itertools 0.14.0", "itertools 0.14.0",
"konst", "konst",
@ -955,7 +955,7 @@ dependencies = [
[[package]] [[package]]
name = "tengri_input" name = "tengri_input"
version = "0.7.0" version = "0.7.1"
dependencies = [ dependencies = [
"tengri_dsl", "tengri_dsl",
"tengri_tui", "tengri_tui",
@ -963,7 +963,7 @@ dependencies = [
[[package]] [[package]]
name = "tengri_output" name = "tengri_output"
version = "0.7.0" version = "0.7.1"
dependencies = [ dependencies = [
"proptest", "proptest",
"proptest-derive", "proptest-derive",
@ -974,7 +974,7 @@ dependencies = [
[[package]] [[package]]
name = "tengri_tui" name = "tengri_tui"
version = "0.7.0" version = "0.7.1"
dependencies = [ dependencies = [
"atomic_float", "atomic_float",
"better-panic", "better-panic",

View file

@ -1,5 +1,5 @@
[workspace.package] [workspace.package]
version = "0.7.0" version = "0.7.1"
[workspace] [workspace]
resolver = "2" resolver = "2"

View file

@ -42,12 +42,3 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
} }
Ok(()) Ok(())
} }
#[cfg(test)] #[test] fn test_dimensions () {
use crate::*;
assert_eq!(Area::center(&[10u16, 10, 20, 20]), [20, 20]);
}
#[cfg(test)] #[test] fn test_layout () -> Usually<()> {
Ok(())
}

View file

@ -1,3 +1,5 @@
use crate::*;
mod align; pub use self::align::*; mod align; pub use self::align::*;
mod bsp; pub use self::bsp::*; mod bsp; pub use self::bsp::*;
mod cond; pub use self::cond::*; mod cond; pub use self::cond::*;

View file

@ -40,20 +40,24 @@ try_from_expr!(<'a, E>: Align<RenderBox<'a, E>>: |state, iter|{
"align/n"|"align/s"|"align/e"|"align/w"| "align/n"|"align/s"|"align/e"|"align/w"|
"align/nw"|"align/sw"|"align/ne"|"align/se" => { "align/nw"|"align/sw"|"align/ne"|"align/se" => {
let _ = iter.next().unwrap(); let _ = iter.next().unwrap();
let c = iter.next().expect("no content specified"); let content = iter.next().expect("no content specified");
let c = state.get_content(&c.value).expect("no content provided"); let content = if let Some(content) = state.get_content(&content.value) {
content
} else {
panic!("no content corresponding to {:?}", &content);
};
return Some(match key { return Some(match key {
"align/c" => Self::c(c), "align/c" => Self::c(content),
"align/x" => Self::x(c), "align/x" => Self::x(content),
"align/y" => Self::y(c), "align/y" => Self::y(content),
"align/n" => Self::n(c), "align/n" => Self::n(content),
"align/s" => Self::s(c), "align/s" => Self::s(content),
"align/e" => Self::e(c), "align/e" => Self::e(content),
"align/w" => Self::w(c), "align/w" => Self::w(content),
"align/nw" => Self::nw(c), "align/nw" => Self::nw(content),
"align/ne" => Self::ne(c), "align/ne" => Self::ne(content),
"align/sw" => Self::sw(c), "align/sw" => Self::sw(content),
"align/se" => Self::se(c), "align/se" => Self::se(content),
_ => unreachable!() _ => unreachable!()
}) })
}, },

View file

@ -22,10 +22,17 @@ impl<A, B> Either<A, B> {
try_from_expr!(<'a, E>: When<RenderBox<'a, E>>: |state, iter| { try_from_expr!(<'a, E>: When<RenderBox<'a, E>>: |state, iter| {
if let Some(Token { value: Value::Key("when"), .. }) = iter.peek() { if let Some(Token { value: Value::Key("when"), .. }) = iter.peek() {
let _ = iter.next().unwrap(); let _ = iter.next().unwrap();
let condition = iter.next().expect("no condition specified"); let condition = iter.next().expect("no condition specified");
let content = iter.next().expect("no content specified");
let condition = state.get(&condition.value).expect("no condition provided"); let condition = state.get(&condition.value).expect("no condition provided");
let content = state.get_content(&content.value).expect("no content provided");
let content = iter.next().expect("no content specified");
let content = if let Some(content) = state.get_content(&content.value) {
content
} else {
panic!("no content corresponding to for {:?}", &content);
};
return Some(Self(condition, content)) return Some(Self(condition, content))
} }
}); });
@ -34,12 +41,24 @@ try_from_expr!(<'a, E>: When<RenderBox<'a, E>>: |state, iter| {
try_from_expr!(<'a, E>: Either<RenderBox<'a, E>, RenderBox<'a, E>>: |state, iter| { try_from_expr!(<'a, E>: Either<RenderBox<'a, E>, RenderBox<'a, E>>: |state, iter| {
if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() { if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() {
let _ = iter.next().unwrap(); let _ = iter.next().unwrap();
let condition = iter.next().expect("no condition specified"); let condition = iter.next().expect("no condition specified");
let content = iter.next().expect("no content specified");
let alternate = iter.next().expect("no alternate specified");
let condition = state.get(&condition.value).expect("no condition provided"); let condition = state.get(&condition.value).expect("no condition provided");
let content = state.get_content(&content.value).expect("no content provided");
let alternate = state.get_content(&alternate.value).expect("no alternate provided"); let content = iter.next().expect("no content specified");
let content = if let Some(content) = state.get_content(&content.value) {
content
} else {
panic!("no content 1 corresponding to {:?}", &content);
};
let alternate = iter.next().expect("no alternate specified");
let alternate = if let Some(alternate) = state.get_content(&alternate.value) {
alternate
} else {
panic!("no content 2 corresponding to {:?}", &alternate);
};
return Some(Self(condition, content, alternate)) return Some(Self(condition, content, alternate))
} }
}); });

View file

@ -90,10 +90,17 @@ macro_rules! transform_xy_unit {
if let Some(Token { value: Value::Key(k), .. }) = iter.peek() { if let Some(Token { value: Value::Key(k), .. }) = iter.peek() {
if k == $x || k == $y { if k == $x || k == $y {
let _ = iter.next().unwrap(); let _ = iter.next().unwrap();
let u = iter.next().expect("no unit specified"); let u = iter.next().expect("no unit specified");
let c = iter.next().expect("no content specified");
let u = state.get(&u.value).expect("no unit provided"); let u = state.get(&u.value).expect("no unit provided");
let c = state.get_content(&c.value).expect("no content provided");
let c = iter.next().expect("no content specified");
let c = if let Some(c) = state.get_content(&c.value) {
c
} else {
panic!("no content corresponding to {:?}", &c);
};
return Some(match k { return Some(match k {
$x => Self::x(u, c), $x => Self::x(u, c),
$y => Self::y(u, c), $y => Self::y(u, c),
@ -101,12 +108,20 @@ macro_rules! transform_xy_unit {
}) })
} else if k == $xy { } else if k == $xy {
let _ = iter.next().unwrap(); let _ = iter.next().unwrap();
let u = iter.next().expect("no unit specified"); let u = iter.next().expect("no unit specified");
let u = state.get(&u.value).expect("no x unit provided");
let v = iter.next().expect("no unit specified"); let v = iter.next().expect("no unit specified");
let v = state.get(&v.value).expect("no y unit provided");
let c = iter.next().expect("no content specified"); let c = iter.next().expect("no content specified");
let u = state.get(&u.value).expect("no unit provided"); let c = if let Some(c) = state.get_content(&c.value) {
let v = state.get(&v.value).expect("no unit provided"); c
let c = state.get_content(&c.value).expect("no content provided"); } else {
panic!("no content corresponding to {:?}", &c);
};
return Some(Self::xy(u, v, c)) return Some(Self::xy(u, v, c))
} }
} }