mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
Compare commits
3 commits
9a12e0c7ba
...
3bc739328e
| Author | SHA1 | Date | |
|---|---|---|---|
| 3bc739328e | |||
| 7ddbace030 | |||
| 921378b6db |
4 changed files with 10 additions and 47 deletions
|
|
@ -25,9 +25,9 @@ try_from_expr!(<'source, 'state, E>: When<RenderBox<'state, E>>: |state, iter| {
|
||||||
let content = iter.next().expect("no content specified").value;
|
let content = iter.next().expect("no content specified").value;
|
||||||
return Some(Self(
|
return Some(Self(
|
||||||
state.get(&mut iter)
|
state.get(&mut iter)
|
||||||
.expect("no condition provided"),
|
.unwrap_or_else(||panic!("cond: no condition: {iter:?}")),
|
||||||
state.get_content(&content)
|
state.get_content(&content)
|
||||||
.unwrap_or_else(||panic!("no content corresponding to for {:?}", &content))
|
.unwrap_or_else(||panic!("cond: no content for {:?}: {iter:?}", &content))
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -35,14 +35,16 @@ try_from_expr!(<'source, 'state, E>: When<RenderBox<'state, E>>: |state, iter| {
|
||||||
#[cfg(feature = "dsl")]
|
#[cfg(feature = "dsl")]
|
||||||
try_from_expr!(<'source, 'state, E>: Either<RenderBox<'state, E>, RenderBox<'state, E>>: |state, iter| {
|
try_from_expr!(<'source, 'state, E>: Either<RenderBox<'state, E>, RenderBox<'state, E>>: |state, iter| {
|
||||||
if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() {
|
if let Some(Token { value: Value::Key("either"), .. }) = iter.peek() {
|
||||||
|
let base = iter.clone();
|
||||||
let _ = iter.next().unwrap();
|
let _ = iter.next().unwrap();
|
||||||
//panic!("{iter:?}");
|
//panic!("{iter:?}");
|
||||||
return Some(Self(
|
return Some(Self(
|
||||||
state.get(&mut iter).expect("no condition provided"),
|
state.get(&mut iter)
|
||||||
|
.unwrap_or_else(||panic!("either: no condition: {base:?}")),
|
||||||
state.get_content(&iter.next().expect("no content specified").value)
|
state.get_content(&iter.next().expect("no content specified").value)
|
||||||
.unwrap_or_else(||panic!("no content 1: {iter:?}")),
|
.unwrap_or_else(||panic!("either: no content 1: {base:?}")),
|
||||||
state.get_content(&iter.next().expect("no alternate specified").value)
|
state.get_content(&iter.next().expect("no alternate specified").value)
|
||||||
.unwrap_or_else(||panic!("no content 2: {iter:?}")),
|
.unwrap_or_else(||panic!("either: no content 2: {base:?}")),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ pub(crate) use proc_macro2::{
|
||||||
TokenStream as TokenStream2, Ident, Span, Punct, Group, Delimiter, Spacing::*
|
TokenStream as TokenStream2, Ident, Span, Punct, Group, Delimiter, Spacing::*
|
||||||
};
|
};
|
||||||
pub(crate) use syn::{
|
pub(crate) use syn::{
|
||||||
parse_macro_input, ImplItem, ImplItemFn, LitStr, Type,
|
parse_macro_input, ImplItem, ImplItemFn, LitStr, Type, TypePath,
|
||||||
ItemImpl, ReturnType, Signature, FnArg, Pat, PatType, PatIdent,
|
ItemImpl, ReturnType, Signature, FnArg, Pat, PatType, PatIdent,
|
||||||
parse::{Parse, ParseStream, Result},
|
parse::{Parse, ParseStream, Result},
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use crate::*;
|
||||||
pub(crate) struct CommandDef(pub(crate) CommandMeta, pub(crate) CommandImpl);
|
pub(crate) struct CommandDef(pub(crate) CommandMeta, pub(crate) CommandImpl);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct CommandMeta(Ident);
|
pub(crate) struct CommandMeta(TypePath);
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub(crate) struct CommandImpl(ItemImpl, BTreeMap<Arc<str>, CommandArm>);
|
pub(crate) struct CommandImpl(ItemImpl, BTreeMap<Arc<str>, CommandArm>);
|
||||||
|
|
@ -14,7 +14,7 @@ struct CommandArm(Ident, Vec<FnArg>, #[allow(unused)] ReturnType);
|
||||||
|
|
||||||
impl Parse for CommandMeta {
|
impl Parse for CommandMeta {
|
||||||
fn parse (input: ParseStream) -> Result<Self> {
|
fn parse (input: ParseStream) -> Result<Self> {
|
||||||
Ok(Self(input.parse::<Ident>()?))
|
Ok(Self(input.parse()?))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,40 +1 @@
|
||||||
use crate::{*, Color::*};
|
use crate::{*, Color::*};
|
||||||
|
|
||||||
pub fn button_2 <'a> (
|
|
||||||
key: impl Content<TuiOut> + 'a, label: impl Content<TuiOut> + 'a, editing: bool,
|
|
||||||
) -> impl Content<TuiOut> + 'a {
|
|
||||||
let key = Tui::fg_bg(Tui::g(0), Tui::orange(), Bsp::e(
|
|
||||||
Tui::fg_bg(Tui::orange(), Reset, "▐"),
|
|
||||||
Bsp::e(key, Tui::fg(Tui::g(96), "▐"))
|
|
||||||
));
|
|
||||||
let label = When::new(!editing, Tui::fg_bg(Tui::g(255), Tui::g(96), label));
|
|
||||||
Tui::bold(true, Bsp::e(key, label))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn button_3 <'a, K, L, V> (
|
|
||||||
key: K,
|
|
||||||
label: L,
|
|
||||||
value: V,
|
|
||||||
editing: bool,
|
|
||||||
) -> impl Content<TuiOut> + 'a where
|
|
||||||
K: Content<TuiOut> + 'a,
|
|
||||||
L: Content<TuiOut> + 'a,
|
|
||||||
V: Content<TuiOut> + 'a,
|
|
||||||
{
|
|
||||||
let key = Tui::fg_bg(Tui::g(0), Tui::orange(),
|
|
||||||
Bsp::e(Tui::fg_bg(Tui::orange(), Reset, "▐"), Bsp::e(key, Tui::fg(if editing {
|
|
||||||
Tui::g(128)
|
|
||||||
} else {
|
|
||||||
Tui::g(96)
|
|
||||||
}, "▐"))));
|
|
||||||
let label = Bsp::e(
|
|
||||||
When::new(!editing, Bsp::e(
|
|
||||||
Tui::fg_bg(Tui::g(255), Tui::g(96), label),
|
|
||||||
Tui::fg_bg(Tui::g(128), Tui::g(96), "▐"),
|
|
||||||
)),
|
|
||||||
Bsp::e(
|
|
||||||
Tui::fg_bg(Tui::g(224), Tui::g(128), value),
|
|
||||||
Tui::fg_bg(Tui::g(128), Reset, "▌"),
|
|
||||||
));
|
|
||||||
Tui::bold(true, Bsp::e(key, label))
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue