mirror of
https://codeberg.org/unspeaker/tek.git
synced 2026-01-31 08:36:40 +01:00
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
Some checks are pending
/ build (push) Waiting to run
Some checks are pending
/ build (push) Waiting to run
This commit is contained in:
parent
d930025422
commit
dcde588c7b
3 changed files with 55 additions and 45 deletions
|
|
@ -1,4 +1,7 @@
|
||||||
pub(crate) use tek::*;
|
pub(crate) use tek::*;
|
||||||
|
pub(crate) use tek_device::*;
|
||||||
|
pub(crate) use tek_engine::*;
|
||||||
|
pub(crate) use tengri::{*, tui::*};
|
||||||
pub(crate) use clap::{self, Parser, Subcommand};
|
pub(crate) use clap::{self, Parser, Subcommand};
|
||||||
|
|
||||||
/// Application entrypoint.
|
/// Application entrypoint.
|
||||||
|
|
@ -6,6 +9,18 @@ pub fn main () -> Usually<()> {
|
||||||
Cli::parse().run()
|
Cli::parse().run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// CLI header
|
||||||
|
const HEADER: &'static str = r#"
|
||||||
|
~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~ ~ ~ ~~ ~ ~ ~ ~~ ~ ~ ~ ~ ~~~~~~ ~ ~~~
|
||||||
|
~~ ║ ~ ╟─╌ ~╟─< ~ v0.3.0, 2025 sum(m)er @ the nose of the cat. ~
|
||||||
|
~~~ ╨ ~ ╙──╜ ╨ ╜ ~ ~~~ ~ ~ ~ ~ ~~~ ~~~ ~ ~~ ~~ ~~ ~ ~~
|
||||||
|
On first run, Tek will create configuration and state dirs:
|
||||||
|
* [x] ~/.config/tek - config
|
||||||
|
* [ ] ~/.local/share/tek - projects
|
||||||
|
* [ ] ~/.local/lib/tek - plugins
|
||||||
|
* [ ] ~/.cache/tek - cache
|
||||||
|
~"#;
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
#[command(name = "tek", version, about = Some(HEADER), long_about = Some(HEADER))]
|
#[command(name = "tek", version, about = Some(HEADER), long_about = Some(HEADER))]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
|
|
@ -49,6 +64,12 @@ pub enum LaunchMode {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Cli {
|
impl Cli {
|
||||||
|
fn midi_froms (&self) -> Vec<Connect> {
|
||||||
|
Connect::collect(&self.midi_from, &[] as &[&str], &self.midi_from_re)
|
||||||
|
}
|
||||||
|
fn midi_tos (&self) -> Vec<Connect> {
|
||||||
|
Connect::collect(&self.midi_to, &[] as &[&str], &self.midi_to_re)
|
||||||
|
}
|
||||||
pub fn run (&self) -> Usually<()> {
|
pub fn run (&self) -> Usually<()> {
|
||||||
let name = self.name.as_ref().map_or("tek", |x|x.as_str());
|
let name = self.name.as_ref().map_or("tek", |x|x.as_str());
|
||||||
let tracks = vec![];
|
let tracks = vec![];
|
||||||
|
|
@ -63,36 +84,39 @@ impl Cli {
|
||||||
let mut config = Config::new(None);
|
let mut config = Config::new(None);
|
||||||
config.init()?;
|
config.init()?;
|
||||||
Tui::new()?.run(&Jack::new_run(&name, move|jack|{
|
Tui::new()?.run(&Jack::new_run(&name, move|jack|{
|
||||||
|
let midi_ins = {
|
||||||
|
let mut midi_ins = vec![];
|
||||||
|
for (index, connect) in self.midi_froms().iter().enumerate() {
|
||||||
|
midi_ins.push(jack.midi_in(&format!("M/{index}"), &[connect.clone()])?);
|
||||||
|
}
|
||||||
|
midi_ins
|
||||||
|
};
|
||||||
|
let midi_outs = {
|
||||||
|
let mut midi_outs = vec![];
|
||||||
|
for (index, connect) in self.midi_tos().iter().enumerate() {
|
||||||
|
midi_outs.push(jack.midi_out(&format!("{index}/M"), &[connect.clone()])?);
|
||||||
|
};
|
||||||
|
midi_outs
|
||||||
|
};
|
||||||
|
let project = Arrangement {
|
||||||
|
name: Default::default(),
|
||||||
|
color: ItemTheme::random(),
|
||||||
|
jack: jack.clone(),
|
||||||
|
clock: Clock::new(&jack, self.bpm)?,
|
||||||
|
tracks,
|
||||||
|
scenes,
|
||||||
|
selection: Selection::TrackClip { track: 0, scene: 0 },
|
||||||
|
midi_ins,
|
||||||
|
midi_outs,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
let app = App {
|
let app = App {
|
||||||
jack: jack.clone(),
|
jack: jack.clone(),
|
||||||
color: ItemTheme::random(),
|
color: ItemTheme::random(),
|
||||||
dialog: Dialog::welcome(),
|
dialog: Dialog::welcome(),
|
||||||
mode: config.modes.clone().read().unwrap().get(":menu").cloned().unwrap(),
|
mode: config.modes.clone().read().unwrap().get(":menu").cloned().unwrap(),
|
||||||
config,
|
config,
|
||||||
project: Arrangement {
|
project,
|
||||||
name: Default::default(),
|
|
||||||
color: ItemTheme::random(),
|
|
||||||
jack: jack.clone(),
|
|
||||||
clock: Clock::new(&jack, self.bpm)?,
|
|
||||||
tracks,
|
|
||||||
scenes,
|
|
||||||
selection: Selection::TrackClip { track: 0, scene: 0 },
|
|
||||||
midi_ins: {
|
|
||||||
let mut midi_ins = vec![];
|
|
||||||
for (index, connect) in self.midi_froms().iter().enumerate() {
|
|
||||||
midi_ins.push(jack.midi_in(&format!("M/{index}"), &[connect.clone()])?);
|
|
||||||
}
|
|
||||||
midi_ins
|
|
||||||
},
|
|
||||||
midi_outs: {
|
|
||||||
let mut midi_outs = vec![];
|
|
||||||
for (index, connect) in self.midi_tos().iter().enumerate() {
|
|
||||||
midi_outs.push(jack.midi_out(&format!("{index}/M"), &[connect.clone()])?);
|
|
||||||
};
|
|
||||||
midi_outs
|
|
||||||
},
|
|
||||||
..Default::default()
|
|
||||||
},
|
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
jack.sync_lead(self.sync_lead, |mut state|{
|
jack.sync_lead(self.sync_lead, |mut state|{
|
||||||
|
|
@ -105,26 +129,8 @@ impl Cli {
|
||||||
Ok(app)
|
Ok(app)
|
||||||
})?)
|
})?)
|
||||||
}
|
}
|
||||||
fn midi_froms (&self) -> Vec<Connect> {
|
|
||||||
Connect::collect(&self.midi_from, &[] as &[&str], &self.midi_from_re)
|
|
||||||
}
|
|
||||||
fn midi_tos (&self) -> Vec<Connect> {
|
|
||||||
Connect::collect(&self.midi_to, &[] as &[&str], &self.midi_to_re)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// CLI header
|
|
||||||
const HEADER: &'static str = r#"
|
|
||||||
~ ╓─╥─╖ ╓──╖ ╥ ╖ ~~~~ ~ ~ ~~ ~ ~ ~ ~~ ~ ~ ~ ~ ~~~~~~ ~ ~~~
|
|
||||||
~~ ║ ~ ╟─╌ ~╟─< ~ v0.3.0, 2025 sum(m)er @ the nose of the cat. ~
|
|
||||||
~~~ ╨ ~ ╙──╜ ╨ ╜ ~ ~~~ ~ ~ ~ ~ ~~~ ~~~ ~ ~~ ~~ ~~ ~ ~~
|
|
||||||
On first run, Tek will create configuration and state dirs:
|
|
||||||
* [x] ~/.config/tek - config
|
|
||||||
* [ ] ~/.local/share/tek - projects
|
|
||||||
* [ ] ~/.local/lib/tek - plugins
|
|
||||||
* [ ] ~/.cache/tek - cache
|
|
||||||
~"#;
|
|
||||||
|
|
||||||
#[cfg(test)] #[test] fn test_cli () {
|
#[cfg(test)] #[test] fn test_cli () {
|
||||||
use clap::CommandFactory;
|
use clap::CommandFactory;
|
||||||
Cli::command().debug_assert();
|
Cli::command().debug_assert();
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
#[allow(unused)]
|
||||||
pub(crate) use ::{
|
pub(crate) use ::{
|
||||||
tek_device::{*, tek_engine::*},
|
tek_device::{*, tek_engine::*},
|
||||||
tengri::{
|
tengri::{
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,8 @@ pub struct Mode<D: Dsl + Ord> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Dsl + Ord> Draw<TuiOut> for Mode<D> {
|
impl<D: Dsl + Ord> Draw<TuiOut> for Mode<D> {
|
||||||
fn draw (&self, to: &mut TuiOut) {
|
fn draw (&self, _to: &mut TuiOut) {
|
||||||
self.content().draw(to)
|
//self.content().draw(to)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -38,7 +38,10 @@ impl Mode<Arc<str>> {
|
||||||
"name" => self.name.push(tail.into()),
|
"name" => self.name.push(tail.into()),
|
||||||
"info" => self.info.push(tail.into()),
|
"info" => self.info.push(tail.into()),
|
||||||
"view" => self.view.push(tail.into()),
|
"view" => self.view.push(tail.into()),
|
||||||
"keys" => tail.each(|expr|{self.keys.push(expr.trim().into()); Ok(())})?,
|
"keys" => tail.each(|expr|{
|
||||||
|
self.keys.push(expr.trim().into());
|
||||||
|
Ok(())
|
||||||
|
})?,
|
||||||
"mode" => if let Some(id) = tail.head()? {
|
"mode" => if let Some(id) = tail.head()? {
|
||||||
Self::load_into(&self.modes, &id, &tail.tail())?;
|
Self::load_into(&self.modes, &id, &tail.tail())?;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue