diff --git a/Justfile b/Justfile index 0a8ec6c5..eab61b0c 100644 --- a/Justfile +++ b/Justfile @@ -26,7 +26,7 @@ clock: cargo run --bin tek -- clock clock-release: reset - cargo run --release --bin tek -- clock + cargo run --release -- clock arranger: reset @@ -44,10 +44,10 @@ arranger-ext: -o "4=Midi-Bridge:Komplete Audio 6 1:(playback_0) Komplete Audio 6 MIDI 1" arranger-release: reset - cargo run --release --bin tek -- arranger + cargo run --release -- arranger arranger-release-ext: reset - cargo run --release --bin tek -- arranger -n tek \ + cargo run --release -- arranger -n tek \ -i "1=Midi-Bridge:nanoKEY Studio 2:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -o "1=Midi-Bridge:Komplete Audio 6 1:(playback_0) Komplete Audio 6 MIDI 1" \ -i "2=Midi-Bridge:nanoKEY Studio 2:(capture_0) nanoKEY Studio nanoKEY Studio _" \ @@ -59,10 +59,10 @@ arranger-release-ext: groovebox: reset - cargo run --bin tek_groovebox -- -b 174 + cargo run -- groovebox -b 174 groovebox-ext: reset - cargo run --bin tek_groovebox -- -n tek \ + cargo run -- groovebox -n tek \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -l "Komplete Audio 6 Pro:capture_AUX1" \ -r "Komplete Audio 6 Pro:capture_AUX1" \ @@ -70,10 +70,10 @@ groovebox-ext: -R "Komplete Audio 6 Pro:playback_AUX1" groovebox-release: reset - cargo run --release --bin tek_groovebox + cargo run --release -- groovebox groovebox-release-ext: reset - cargo run --release --bin tek_groovebox -- -n tek \ + cargo run --release -- groovebox -n tek \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -l "Komplete Audio 6 Pro:capture_AUX1" \ -r "Komplete Audio 6 Pro:capture_AUX1" \ @@ -81,7 +81,7 @@ groovebox-release-ext: -R "Komplete Audio 6 Pro:playback_AUX2" groovebox-release-ext-browser: reset - cargo run --release --bin tek_groovebox -- -n tek \ + cargo run --release -- groovebox -n tek \ -b 112 \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -l "Firefox:output_FL" \ @@ -91,33 +91,27 @@ groovebox-release-ext-browser: sequencer: reset - cargo run --bin tek_sequencer + cargo run -- sequencer sequencer-ext: reset - cargo run --bin tek_sequencer -- \ + cargo run -- sequencer \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -o "Midi-Bridge:Komplete Audio 6 0:(playback_0) Komplete Audio 6 MIDI 1" sequencer-release: - reset - cargo run --release --bin tek_sequencer + reset cargo run --release -- sequencer sequencer-release-ext: - reset - cargo run --release --bin tek_sequencer -- \ + reset && cargo run --release -- sequencer \ -i "Midi-Bridge:nanoKEY Studio 1:(capture_0) nanoKEY Studio nanoKEY Studio _" \ -o "Midi-Bridge:Komplete Audio 6 0:(playback_0) Komplete Audio 6 MIDI 1" mixer: - reset - cargo run --bin tek_mixer + reset && cargo run -- mixer track: - reset - cargo run --bin tek_track + reset && cargo run -- track sampler: - reset - cargo run --bin tek_sampler + reset && cargo run -- sampler plugin: - reset - cargo run --bin tek_plugin + reset && cargo run -- plugin edn: reset diff --git a/edn/src/lib.rs b/edn/src/lib.rs index fa7c5bc4..90f6fcd9 100644 --- a/edn/src/lib.rs +++ b/edn/src/lib.rs @@ -8,9 +8,6 @@ mod edn_item; pub use self::edn_item::*; mod edn_iter; pub use self::edn_iter::*; mod edn_token; pub use self::edn_token::*; -#[cfg(feature = "tek_output")] -pub(crate) use ::tek_output::*; - #[cfg(test)] #[test] fn test_edn () -> Result<(), ParseError> { use EdnItem::*; assert_eq!(EdnItem::::read_all("")?, diff --git a/input/src/command.rs b/input/src/command.rs index b640dc9b..9e91b304 100644 --- a/input/src/command.rs +++ b/input/src/command.rs @@ -1,39 +1,4 @@ use crate::*; -pub trait Command: Send + Sync + Sized { - fn execute (self, state: &mut S) -> Perhaps; - fn delegate (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps { - Ok(self.execute(state)?.map(wrap)) - } -} -#[macro_export] macro_rules! input_to_command { - (<$($l:lifetime),+> $Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => { - impl<$($l),+> InputToCommand<$Input, $State> for $Command { - fn input_to_command ($state: &$State, $input: &$Input) -> Option { - Some($handler) - } - } - }; - ($Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => { - impl InputToCommand<$Input, $State> for $Command { - fn input_to_command ($state: &$State, $input: &$Input) -> Option { - Some($handler) - } - } - } -} - -pub trait InputToCommand: Command + Sized { - fn input_to_command (state: &S, input: &I) -> Option; - fn execute_with_state (state: &mut S, input: &I) -> Perhaps { - Ok(if let Some(command) = Self::input_to_command(state, input) { - let _undo = command.execute(state)?; - Some(true) - } else { - None - }) - } -} - #[macro_export] macro_rules! command { ($(<$($l:lifetime),+>)?|$self:ident:$Command:ty,$state:ident:$State:ty|$handler:expr) => { impl$(<$($l),+>)? Command<$State> for $Command { @@ -43,3 +8,9 @@ pub trait InputToCommand: Command + Sized { } }; } +pub trait Command: Send + Sync + Sized { + fn execute (self, state: &mut S) -> Perhaps; + fn delegate (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps { + Ok(self.execute(state)?.map(wrap)) + } +} diff --git a/input/src/engine.rs b/input/src/engine.rs index e6b8e955..6c3c78b8 100644 --- a/input/src/engine.rs +++ b/input/src/engine.rs @@ -1,5 +1,3 @@ -use crate::*; - /// Event source pub trait Input: Send + Sync + Sized { /// Type of input event diff --git a/input/src/event_map.rs b/input/src/event_map.rs index ee735217..bab7d934 100644 --- a/input/src/event_map.rs +++ b/input/src/event_map.rs @@ -1,9 +1,8 @@ -use crate::*; - pub struct EventMap<'a, S, I: PartialEq, C> { pub bindings: &'a [(I, &'a dyn Fn(&S) -> Option)], pub fallback: Option<&'a dyn Fn(&S, &I) -> Option> } + impl<'a, S, I: PartialEq, C> EventMap<'a, S, I, C> { pub fn handle (&self, state: &S, input: &I) -> Option { for (binding, handler) in self.bindings.iter() { diff --git a/input/src/input.rs b/input/src/input.rs new file mode 100644 index 00000000..ea6bbc5e --- /dev/null +++ b/input/src/input.rs @@ -0,0 +1,30 @@ +use crate::*; +#[macro_export] macro_rules! input_to_command { + (<$($l:lifetime),+> $Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => { + impl<$($l),+> InputToCommand<$Input, $State> for $Command { + fn input_to_command ($state: &$State, $input: &$Input) -> Option { + Some($handler) + } + } + }; + ($Command:ty: |$state:ident:$State:ty, $input:ident:$Input:ty| $handler:expr) => { + impl InputToCommand<$Input, $State> for $Command { + fn input_to_command ($state: &$State, $input: &$Input) -> Option { + Some($handler) + } + } + } +} + +pub trait InputToCommand: Command + Sized { + fn input_to_command (state: &S, input: &I) -> Option; + fn execute_with_state (state: &mut S, input: &I) -> Perhaps { + Ok(if let Some(command) = Self::input_to_command(state, input) { + let _undo = command.execute(state)?; + Some(true) + } else { + None + }) + } +} + diff --git a/input/src/lib.rs b/input/src/lib.rs index e2cf0da5..fba57784 100644 --- a/input/src/lib.rs +++ b/input/src/lib.rs @@ -1,9 +1,10 @@ #![feature(associated_type_defaults)] //mod component; pub use self::component::*; -mod engine; pub use self::engine::*; -mod handle; pub use self::handle::*; -mod command; pub use self::command::*; +mod engine; pub use self::engine::*; +mod input; pub use self::input::*; +mod handle; pub use self::handle::*; +mod command; pub use self::command::*; mod event_map; pub use self::event_map::*; pub(crate) use std::marker::PhantomData; diff --git a/jack/src/lib.rs b/jack/src/lib.rs index d2fa3bd6..5689c22f 100644 --- a/jack/src/lib.rs +++ b/jack/src/lib.rs @@ -5,9 +5,8 @@ pub use ::jack; pub(crate) use ::jack::{ contrib::ClosureProcessHandler, NotificationHandler, Client, AsyncClient, ClientOptions, ClientStatus, - ProcessScope, Control, CycleTimes, Frames, + ProcessScope, Control, Frames, Port, PortId, PortSpec, Unowned, MidiIn, MidiOut, AudioIn, AudioOut, - Transport, TransportState, MidiIter, MidiWriter, RawMidi, }; mod from_jack; pub use self::from_jack::*; diff --git a/output/src/edn_view.rs b/output/src/edn_view.rs index 29052e46..86dc3fb4 100644 --- a/output/src/edn_view.rs +++ b/output/src/edn_view.rs @@ -2,11 +2,11 @@ use crate::*; use std::marker::PhantomData; use EdnItem::*; -pub type EdnCallback<'a, Output, State> = - dyn Fn(&'a State)-> RenderBox<'a, Output> + Send + Sync + 'a; +pub type EdnCallback<'a, O: Output, State> = + dyn Fn(&'a State)-> RenderBox<'a, O> + Send + Sync + 'a; -pub type EdnRenderCallback<'a, Output, State> = - Box>; +pub type EdnRenderCallback<'a, O: Output, State> = + Box>; /// Provides values to the template pub trait EdnViewData { @@ -49,11 +49,10 @@ impl + Send + Sync> Content for EdnView { match_exp(s, &head.to_ref(), &tail) } else { panic!("todo: add error handling to content() chain. invalid expression {e:?}"); - ().boxed() }, }, - Self::Err(error) => { - Box::new(())//&format!("EdnView error: {error:?}")) + Self::Err(_error) => { + Box::new(())//&format!("EdnView error: {error:?}")) // FIXME: String is not Render }, _ => todo!() } diff --git a/output/src/lib.rs b/output/src/lib.rs index 7c4cfbfa..c8c614e2 100644 --- a/output/src/lib.rs +++ b/output/src/lib.rs @@ -1,3 +1,4 @@ +//#![feature(lazy_type_alias)] #![feature(type_alias_impl_trait)] #![feature(impl_trait_in_assoc_type)] @@ -29,10 +30,10 @@ pub(crate) use std::marker::PhantomData; pub(crate) use std::error::Error; /// Standard result type. -pub(crate) type Usually = Result>; +pub type Usually = Result>; /// Standard optional result type. -pub(crate) type Perhaps = Result, Box>; +pub type Perhaps = Result, Box>; #[cfg(test)] #[test] fn test_layout () -> Usually<()> { use ::tek_tui::Tui; diff --git a/tui/src/lib.rs b/tui/src/lib.rs index 19e77380..bc68ac92 100644 --- a/tui/src/lib.rs +++ b/tui/src/lib.rs @@ -27,12 +27,6 @@ pub(crate) use std::error::Error; pub(crate) use std::path::PathBuf; pub(crate) use std::ffi::OsString; -/// Standard result type. -pub type Usually = Result>; - -/// Standard optional result type. -pub type Perhaps = Result, Box>; - /// Prototypal case of implementor macro. /// Saves 4loc per data pats. #[macro_export] macro_rules! from {