mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2026-04-03 21:40:44 +02:00
Compare commits
2 commits
04db6f4af5
...
b4ebdb8ff8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4ebdb8ff8 | ||
|
|
7a8365c017 |
4 changed files with 17 additions and 20 deletions
|
|
@ -15,7 +15,7 @@ pub(crate) use std::ops::{Add, Sub, Mul, Div};
|
||||||
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::Relaxed}};
|
pub(crate) use std::sync::{Arc, RwLock, atomic::{AtomicUsize, Ordering::Relaxed}};
|
||||||
pub(crate) use std::marker::PhantomData;
|
pub(crate) use std::marker::PhantomData;
|
||||||
pub(crate) use dizzle::*;
|
pub(crate) use dizzle::*;
|
||||||
pub(crate) use quanta::Clock;
|
//pub(crate) use quanta::Clock;
|
||||||
pub(crate) use atomic_float::AtomicF64;
|
pub(crate) use atomic_float::AtomicF64;
|
||||||
|
|
||||||
// Define macros first, so that private macros are available in private modules:
|
// Define macros first, so that private macros are available in private modules:
|
||||||
|
|
@ -189,12 +189,12 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
|
||||||
match frags.next() {
|
match frags.next() {
|
||||||
|
|
||||||
Some("when") => output.place(&When::new(
|
Some("when") => output.place(&When::new(
|
||||||
state.resolve(arg0?)?.unwrap(),
|
state.namespace(arg0?)?.unwrap(),
|
||||||
Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap())
|
Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap())
|
||||||
)),
|
)),
|
||||||
|
|
||||||
Some("either") => output.place(&Either::new(
|
Some("either") => output.place(&Either::new(
|
||||||
state.resolve(arg0?)?.unwrap(),
|
state.namespace(arg0?)?.unwrap(),
|
||||||
Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap()),
|
Thunk::new(move|output: &mut O|state.view(output, &arg1).unwrap()),
|
||||||
Thunk::new(move|output: &mut O|state.view(output, &arg2).unwrap())
|
Thunk::new(move|output: &mut O|state.view(output, &arg2).unwrap())
|
||||||
)),
|
)),
|
||||||
|
|
@ -242,9 +242,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
|
||||||
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
||||||
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
||||||
match axis {
|
match axis {
|
||||||
Some("xy") | None => Fixed::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb),
|
Some("xy") | None => Fixed::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
|
||||||
Some("x") => Fixed::X(state.resolve(arg0?)?.unwrap(), cb),
|
Some("x") => Fixed::X(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
Some("y") => Fixed::Y(state.resolve(arg0?)?.unwrap(), cb),
|
Some("y") => Fixed::Y(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
frag => unimplemented!("fixed/{frag:?} ({expr:?}) ({head:?}) ({:?})",
|
frag => unimplemented!("fixed/{frag:?} ({expr:?}) ({head:?}) ({:?})",
|
||||||
head.src()?.unwrap_or_default().split("/").next())
|
head.src()?.unwrap_or_default().split("/").next())
|
||||||
}
|
}
|
||||||
|
|
@ -255,9 +255,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
|
||||||
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
||||||
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
||||||
match axis {
|
match axis {
|
||||||
Some("xy") | None => Min::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb),
|
Some("xy") | None => Min::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
|
||||||
Some("x") => Min::X(state.resolve(arg0?)?.unwrap(), cb),
|
Some("x") => Min::X(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
Some("y") => Min::Y(state.resolve(arg0?)?.unwrap(), cb),
|
Some("y") => Min::Y(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
frag => unimplemented!("min/{frag:?}")
|
frag => unimplemented!("min/{frag:?}")
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -267,9 +267,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
|
||||||
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
||||||
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
||||||
match axis {
|
match axis {
|
||||||
Some("xy") | None => Max::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb),
|
Some("xy") | None => Max::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
|
||||||
Some("x") => Max::X(state.resolve(arg0?)?.unwrap(), cb),
|
Some("x") => Max::X(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
Some("y") => Max::Y(state.resolve(arg0?)?.unwrap(), cb),
|
Some("y") => Max::Y(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
frag => unimplemented!("max/{frag:?}")
|
frag => unimplemented!("max/{frag:?}")
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
@ -279,9 +279,9 @@ pub fn evaluate_output_expression <'a, O: Out + 'a, S> (
|
||||||
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
let arg = match axis { Some("x") | Some("y") => arg1, Some("xy") | None => arg2, _ => panic!("fixed: unsupported axis {axis:?}") };
|
||||||
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
let cb = Thunk::new(move|output: &mut O|state.view(output, &arg).unwrap());
|
||||||
match axis {
|
match axis {
|
||||||
Some("xy") | None => Push::XY(state.resolve(arg0?)?.unwrap(), state.resolve(arg1?)?.unwrap(), cb),
|
Some("xy") | None => Push::XY(state.namespace(arg0?)?.unwrap(), state.namespace(arg1?)?.unwrap(), cb),
|
||||||
Some("x") => Push::X(state.resolve(arg0?)?.unwrap(), cb),
|
Some("x") => Push::X(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
Some("y") => Push::Y(state.resolve(arg0?)?.unwrap(), cb),
|
Some("y") => Push::Y(state.namespace(arg0?)?.unwrap(), cb),
|
||||||
frag => unimplemented!("push/{frag:?}")
|
frag => unimplemented!("push/{frag:?}")
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
use crate::*;
|
use crate::*;
|
||||||
use Direction::*;
|
|
||||||
use Alignment::*;
|
use Alignment::*;
|
||||||
|
|
||||||
impl Coord for u16 {
|
impl Coord for u16 {
|
||||||
|
|
|
||||||
|
|
@ -76,8 +76,6 @@ pub trait View<O, U> {
|
||||||
Err(format!("View::view_word: no words defined: {word:?}").into())
|
Err(format!("View::view_word: no words defined: {word:?}").into())
|
||||||
}
|
}
|
||||||
fn view <'a> (&'a self, output: &mut O, dsl: &'a impl Language) -> Usually<U> {
|
fn view <'a> (&'a self, output: &mut O, dsl: &'a impl Language) -> Usually<U> {
|
||||||
let is_expr = dsl.expr();
|
|
||||||
let is_word = dsl.word();
|
|
||||||
match (dsl.expr(), dsl.word()) {
|
match (dsl.expr(), dsl.word()) {
|
||||||
(Ok(Some(e)), _ ) => self.view_expr(output, &e),
|
(Ok(Some(e)), _ ) => self.view_expr(output, &e),
|
||||||
(_, Ok(Some(w))) => self.view_word(output, &w),
|
(_, Ok(Some(w))) => self.view_word(output, &w),
|
||||||
|
|
|
||||||
|
|
@ -262,7 +262,7 @@ pub fn tui_input <T: Handle<TuiIn> + Send + Sync + 'static> (
|
||||||
Some("fg") => {
|
Some("fg") => {
|
||||||
let arg0 = arg0?.expect("fg: expected arg 0 (color)");
|
let arg0 = arg0?.expect("fg: expected arg 0 (color)");
|
||||||
output.place(&Tui::fg(
|
output.place(&Tui::fg(
|
||||||
Namespace::<Color>::resolve(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")),
|
Namespace::<Color>::namespace(state, arg0)?.unwrap_or_else(||panic!("fg: {arg0:?}: not a color")),
|
||||||
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
|
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
|
|
@ -270,7 +270,7 @@ pub fn tui_input <T: Handle<TuiIn> + Send + Sync + 'static> (
|
||||||
Some("bg") => {
|
Some("bg") => {
|
||||||
let arg0 = arg0?.expect("bg: expected arg 0 (color)");
|
let arg0 = arg0?.expect("bg: expected arg 0 (color)");
|
||||||
output.place(&Tui::bg(
|
output.place(&Tui::bg(
|
||||||
Namespace::<Color>::resolve(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")),
|
Namespace::<Color>::namespace(state, arg0)?.unwrap_or_else(||panic!("bg: {arg0:?}: not a color")),
|
||||||
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
|
Thunk::new(move|output: &mut TuiOut|state.view(output, &arg1).unwrap()),
|
||||||
))
|
))
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue