diff --git a/output/src/ops/cond.rs b/output/src/ops/cond.rs index 578210e..902a2dc 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) - .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>: |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) - .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:?}")), )) } }); diff --git a/proc/src/lib.rs b/proc/src/lib.rs index 02ba5de..132d416 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, TypePath, + parse_macro_input, ImplItem, ImplItemFn, LitStr, Type, 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 123b11b..f8e9d2a 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(TypePath); +pub(crate) struct CommandMeta(Ident); #[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 ec58935..2a297da 100644 --- a/tui/src/tui_content/tui_button.rs +++ b/tui/src/tui_content/tui_button.rs @@ -1 +1,40 @@ 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)) +}