'197e' is as much as i can tell ya

This commit is contained in:
i do not exist 2026-04-13 17:31:15 +03:00
parent dcca74a649
commit 5ffa9472e1
7 changed files with 975 additions and 948 deletions

View file

@ -46,6 +46,7 @@ pub mod clock;
pub mod config;
pub mod device;
pub mod dialog;
pub mod editor;
pub mod menu;
pub mod mix;
pub mod mode;
@ -57,16 +58,17 @@ pub mod view;
#[cfg(feature = "plugin")] pub mod plugin;
use clap::{self, Parser, Subcommand};
use builder_pattern::Builder;
use self::{
arrange::*, clock::*, dialog::*, browse::*, select::*, sequence::*, device::*,
config::*, mode::*, view::*, bind::*, sample::*, menu::*
config::*, mode::*, view::*, bind::*,
dialog::*, browse::*, menu::*,
clock::*, sequence::*, editor::*,
arrange::*, select::*, device::*, sample::*,
};
extern crate xdg;
pub(crate) use ::xdg::BaseDirectories;
pub extern crate atomic_float;
pub(crate) use atomic_float::AtomicF64;
//pub(crate) use atomic_float::AtomicF64;
//pub extern crate jack;
//pub(crate) use ::jack::{*, contrib::{*, ClosureProcessHandler}};
pub extern crate midly;
@ -198,34 +200,39 @@ fn tek_dec (state: &mut App, axis: &ControlAxis) -> Perhaps<AppCommand> {
})
}
fn collect_commands (app: &App, input: &TuiIn) -> Usually<Vec<AppCommand>> {
let mut commands = vec![];
for id in app.mode.keys.iter() {
if let Some(event_map) = app.config.binds.clone().read().unwrap().get(id.as_ref())
&& let Some(bindings) = event_map.query(input.event()) {
for binding in bindings {
for command in binding.commands.iter() {
if let Some(command) = app.namespace(command)? as Option<AppCommand> {
commands.push(command)
}
}
}
}
}
Ok(commands)
}
fn execute_commands (
app: &mut App, commands: Vec<AppCommand>
) -> Usually<Vec<(AppCommand, Option<AppCommand>)>> {
let mut history = vec![];
for command in commands.into_iter() {
let result = command.act(app);
match result { Err(err) => { history.push((command, None)); return Err(err) }
Ok(undo) => { history.push((command, undo)); } };
}
Ok(history)
}
//impl_handle!(TuiIn: |self: App, input|{
//let commands = tek_collect_commands(self, input)?;
//let history = tek_execute_commands(self, commands)?;
//self.history.extend(history.into_iter());
//Ok(None)
//});
//fn tek_collect_commands (app: &App, input: &TuiIn) -> Usually<Vec<AppCommand>> {
//let mut commands = vec![];
//for id in app.mode.keys.iter() {
//if let Some(event_map) = app.config.binds.clone().read().unwrap().get(id.as_ref())
//&& let Some(bindings) = event_map.query(input.event()) {
//for binding in bindings {
//for command in binding.commands.iter() {
//if let Some(command) = app.namespace(command)? as Option<AppCommand> {
//commands.push(command)
//}
//}
//}
//}
//}
//Ok(commands)
//}
//fn tek_execute_commands (
//app: &mut App, commands: Vec<AppCommand>
//) -> Usually<Vec<(AppCommand, Option<AppCommand>)>> {
//let mut history = vec![];
//for command in commands.into_iter() {
//let result = command.act(app);
//match result { Err(err) => { history.push((command, None)); return Err(err) }
//Ok(undo) => { history.push((command, undo)); } };
//}
//Ok(history)
//}
pub fn tek_jack_process (app: &mut App, client: &Client, scope: &ProcessScope) -> Control {
let t0 = app.perf.get_t0();
@ -590,7 +597,7 @@ pub(crate) const HEADER: &'static str = r#"
/// Must not be dropped for the duration of the process
pub jack: Jack<'static>,
/// Display size
pub size: [AtomicUsize;2],
pub size: Size,
/// Performance counter
pub perf: PerfModel,
/// Available view modes and input bindings
@ -613,7 +620,7 @@ impl_has!(Vec<MidiInput>: |self: App|self.project.midi_ins);
impl_has!(Vec<MidiOutput>: |self: App|self.project.midi_outs);
impl_has!(Dialog: |self: App|self.dialog);
impl_has!(Jack<'static>: |self: App|self.jack);
impl_has!([AtomicUsize;2]: |self: App|self.size);
impl_has!(Size: |self: App|self.size);
impl_has!(Pool: |self: App|self.pool);
impl_has!(Selection: |self: App|self.project.selection);
impl_as_ref!(Vec<Scene>: |self: App|self.project.as_ref());
@ -622,17 +629,11 @@ impl_as_ref_opt!(MidiEditor: |self: App|self.project.as_ref_opt());
impl_as_mut_opt!(MidiEditor: |self: App|self.project.as_mut_opt());
impl_has_clips!( |self: App|self.pool.clips);
impl_audio!(App: tek_jack_process, tek_jack_event);
impl_handle!(TuiIn: |self: App, input|{
let commands = collect_commands(self, input)?;
let history = execute_commands(self, commands)?;
self.history.extend(history.into_iter());
Ok(None)
});
namespace!(App: Arc<str> { literal = |dsl|Ok(dsl.src()?.map(|x|x.into())); });
namespace!(App: u8 { literal = |dsl|try_to_u8(dsl); });
namespace!(App: u16 { literal = |dsl|try_to_u16(dsl); symbol = |app| {
":w/sidebar" => app.project.w_sidebar(app.editor().is_some()),
":h/sample-detail" => 6.max(app.measure_height() as u16 * 3 / 9), }; });
":h/sample-detail" => 6.max(app.size.h() as u16 * 3 / 9), }; });
namespace!(App: isize { literal = |dsl|try_to_isize(dsl); });
namespace!(App: usize { literal = |dsl|try_to_usize(dsl); symbol = |app| {
":scene-count" => app.scenes().len(),
@ -690,7 +691,7 @@ namespace!(App: Option<Arc<RwLock<MidiClip>>> {
};
});
pub trait HasClipsSize { fn clips_size (&self) -> &[AtomicUsize;2]; }
pub trait HasClipsSize { fn clips_size (&self) -> &Size; }
pub trait HasDevices: AsRef<Vec<Device>> + AsMut<Vec<Device>> {
fn devices (&self) -> &Vec<Device> { self.as_ref() }
@ -966,7 +967,7 @@ impl Draw<Tui> for App {
}
}
}
impl HasClipsSize for App { fn clips_size (&self) -> &[AtomicUsize;2] { &self.project.size_inner } }
impl HasClipsSize for App { fn clips_size (&self) -> &Size { &self.project.size_inner } }
impl HasJack<'static> for App { fn jack (&self) -> &Jack<'static> { &self.jack } }
impl_default!(AppCommand: Self::Nop);
primitive!(u8: try_to_u8);