diff --git a/output/src/ops/cond.rs b/output/src/ops/cond.rs index 902a2dc..578210e 100644 --- a/output/src/ops/cond.rs +++ b/output/src/ops/cond.rs @@ -25,9 +25,9 @@ try_from_expr!(<'source, 'state, E>: When>: |state, iter| { let content = iter.next().expect("no content specified").value; return Some(Self( state.get(&mut iter) - .expect("no condition provided"), + .unwrap_or_else(||panic!("cond: no condition: {iter:?}")), 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>: |state, iter| { #[cfg(feature = "dsl")] try_from_expr!(<'source, 'state, E>: Either, 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).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) - .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) - .unwrap_or_else(||panic!("no content 2: {iter:?}")), + .unwrap_or_else(||panic!("either: no content 2: {base:?}")), )) } }); diff --git a/proc/src/lib.rs b/proc/src/lib.rs index 132d416..02ba5de 100644 --- a/proc/src/lib.rs +++ b/proc/src/lib.rs @@ -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, + parse_macro_input, ImplItem, ImplItemFn, LitStr, Type, TypePath, ItemImpl, ReturnType, Signature, FnArg, Pat, PatType, PatIdent, parse::{Parse, ParseStream, Result}, }; diff --git a/proc/src/proc_command.rs b/proc/src/proc_command.rs index f8e9d2a..123b11b 100644 --- a/proc/src/proc_command.rs +++ b/proc/src/proc_command.rs @@ -4,7 +4,7 @@ use crate::*; pub(crate) struct CommandDef(pub(crate) CommandMeta, pub(crate) CommandImpl); #[derive(Debug, Clone)] -pub(crate) struct CommandMeta(Ident); +pub(crate) struct CommandMeta(TypePath); #[derive(Debug, Clone)] pub(crate) struct CommandImpl(ItemImpl, BTreeMap, CommandArm>); @@ -14,7 +14,7 @@ struct CommandArm(Ident, Vec, #[allow(unused)] ReturnType); impl Parse for CommandMeta { fn parse (input: ParseStream) -> Result { - Ok(Self(input.parse::()?)) + Ok(Self(input.parse()?)) } } diff --git a/tui/src/tui_content/tui_button.rs b/tui/src/tui_content/tui_button.rs index 2a297da..ec58935 100644 --- a/tui/src/tui_content/tui_button.rs +++ b/tui/src/tui_content/tui_button.rs @@ -1,40 +1 @@ use crate::{*, Color::*}; - -pub fn button_2 <'a> ( - key: impl Content + 'a, label: impl Content + 'a, editing: bool, -) -> impl Content + '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 + 'a where - K: Content + 'a, - L: Content + 'a, - V: Content + '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)) -}