update Justfile and fix some warnings

This commit is contained in:
🪞👃🪞 2025-01-09 18:56:32 +01:00
parent 9e4406c66a
commit b995f81a26
11 changed files with 67 additions and 84 deletions

View file

@ -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

View file

@ -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::<String>::read_all("")?,

View file

@ -1,39 +1,4 @@
use crate::*;
pub trait Command<S>: Send + Sync + Sized {
fn execute (self, state: &mut S) -> Perhaps<Self>;
fn delegate <T> (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps<T> {
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<Self> {
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<Self> {
Some($handler)
}
}
}
}
pub trait InputToCommand<I, S>: Command<S> + Sized {
fn input_to_command (state: &S, input: &I) -> Option<Self>;
fn execute_with_state (state: &mut S, input: &I) -> Perhaps<bool> {
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<I, S>: Command<S> + Sized {
}
};
}
pub trait Command<S>: Send + Sync + Sized {
fn execute (self, state: &mut S) -> Perhaps<Self>;
fn delegate <T> (self, state: &mut S, wrap: impl Fn(Self)->T) -> Perhaps<T> {
Ok(self.execute(state)?.map(wrap))
}
}

View file

@ -1,5 +1,3 @@
use crate::*;
/// Event source
pub trait Input: Send + Sync + Sized {
/// Type of input event

View file

@ -1,9 +1,8 @@
use crate::*;
pub struct EventMap<'a, S, I: PartialEq, C> {
pub bindings: &'a [(I, &'a dyn Fn(&S) -> Option<C>)],
pub fallback: Option<&'a dyn Fn(&S, &I) -> Option<C>>
}
impl<'a, S, I: PartialEq, C> EventMap<'a, S, I, C> {
pub fn handle (&self, state: &S, input: &I) -> Option<C> {
for (binding, handler) in self.bindings.iter() {

30
input/src/input.rs Normal file
View file

@ -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<Self> {
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<Self> {
Some($handler)
}
}
}
}
pub trait InputToCommand<I, S>: Command<S> + Sized {
fn input_to_command (state: &S, input: &I) -> Option<Self>;
fn execute_with_state (state: &mut S, input: &I) -> Perhaps<bool> {
Ok(if let Some(command) = Self::input_to_command(state, input) {
let _undo = command.execute(state)?;
Some(true)
} else {
None
})
}
}

View file

@ -2,6 +2,7 @@
//mod component; pub use self::component::*;
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::*;

View file

@ -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::*;

View file

@ -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<EdnCallback<'a, Output, State>>;
pub type EdnRenderCallback<'a, O: Output, State> =
Box<EdnCallback<'a, O, State>>;
/// Provides values to the template
pub trait EdnViewData<E: Output> {
@ -49,11 +49,10 @@ impl<E: Output, T: EdnViewData<E> + Send + Sync> Content<E> for EdnView<E, T> {
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!()
}

View file

@ -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<T> = Result<T, Box<dyn Error>>;
pub type Usually<T> = Result<T, Box<dyn Error>>;
/// Standard optional result type.
pub(crate) type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
#[cfg(test)] #[test] fn test_layout () -> Usually<()> {
use ::tek_tui::Tui;

View file

@ -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<T> = Result<T, Box<dyn Error>>;
/// Standard optional result type.
pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
/// Prototypal case of implementor macro.
/// Saves 4loc per data pats.
#[macro_export] macro_rules! from {