mirror of
https://codeberg.org/unspeaker/tengri.git
synced 2025-12-06 11:46:42 +01:00
Compare commits
No commits in common. "3bc739328eed0c8fa67b432c7354c7929ddb505f" and "9a12e0c7bab24cb708d503e860d93677ae306961" have entirely different histories.
3bc739328e
...
9a12e0c7ba
4 changed files with 47 additions and 10 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;
|
||||
return Some(Self(
|
||||
state.get(&mut iter)
|
||||
.unwrap_or_else(||panic!("cond: no condition: {iter:?}")),
|
||||
.expect("no condition provided"),
|
||||
state.get_content(&content)
|
||||
.unwrap_or_else(||panic!("cond: no content for {:?}: {iter:?}", &content))
|
||||
.unwrap_or_else(||panic!("no content corresponding to for {:?}", &content))
|
||||
))
|
||||
}
|
||||
});
|
||||
|
|
@ -35,16 +35,14 @@ try_from_expr!(<'source, 'state, E>: When<RenderBox<'state, E>>: |state, iter| {
|
|||
#[cfg(feature = "dsl")]
|
||||
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() {
|
||||
let base = iter.clone();
|
||||
let _ = iter.next().unwrap();
|
||||
//panic!("{iter:?}");
|
||||
return Some(Self(
|
||||
state.get(&mut iter)
|
||||
.unwrap_or_else(||panic!("either: no condition: {base:?}")),
|
||||
state.get(&mut iter).expect("no condition provided"),
|
||||
state.get_content(&iter.next().expect("no content specified").value)
|
||||
.unwrap_or_else(||panic!("either: no content 1: {base:?}")),
|
||||
.unwrap_or_else(||panic!("no content 1: {iter:?}")),
|
||||
state.get_content(&iter.next().expect("no alternate specified").value)
|
||||
.unwrap_or_else(||panic!("either: no content 2: {base:?}")),
|
||||
.unwrap_or_else(||panic!("no content 2: {iter:?}")),
|
||||
))
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ pub(crate) use proc_macro2::{
|
|||
TokenStream as TokenStream2, Ident, Span, Punct, Group, Delimiter, Spacing::*
|
||||
};
|
||||
pub(crate) use syn::{
|
||||
parse_macro_input, ImplItem, ImplItemFn, LitStr, Type, TypePath,
|
||||
parse_macro_input, ImplItem, ImplItemFn, LitStr, Type,
|
||||
ItemImpl, ReturnType, Signature, FnArg, Pat, PatType, PatIdent,
|
||||
parse::{Parse, ParseStream, Result},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use crate::*;
|
|||
pub(crate) struct CommandDef(pub(crate) CommandMeta, pub(crate) CommandImpl);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub(crate) struct CommandMeta(TypePath);
|
||||
pub(crate) struct CommandMeta(Ident);
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
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 {
|
||||
fn parse (input: ParseStream) -> Result<Self> {
|
||||
Ok(Self(input.parse()?))
|
||||
Ok(Self(input.parse::<Ident>()?))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +1,40 @@
|
|||
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