mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
big flat pt.13: fixed warnings, let's see what it has in store
This commit is contained in:
parent
e21ef1af94
commit
5bc3517dde
13 changed files with 68 additions and 45 deletions
|
|
@ -30,15 +30,16 @@ impl ArrangerCli {
|
||||||
/// Run the arranger TUI from CLI arguments.
|
/// Run the arranger TUI from CLI arguments.
|
||||||
fn run (&self) -> Usually<()> {
|
fn run (&self) -> Usually<()> {
|
||||||
let name = self.name.as_deref().unwrap_or("tek_arranger");
|
let name = self.name.as_deref().unwrap_or("tek_arranger");
|
||||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
let engine = Tui::new()?;
|
||||||
|
let state = JackConnection::new(name)?.activate_with(|jack|{
|
||||||
let mut app = ArrangerTui::try_from(jack)?;
|
let mut app = ArrangerTui::try_from(jack)?;
|
||||||
let jack = jack.read().unwrap();
|
let jack = jack.read().unwrap();
|
||||||
app.color = ItemPalette::random();
|
app.color = ItemPalette::random();
|
||||||
add_tracks(&jack, &mut app, self)?;
|
add_tracks(&jack, &mut app, self)?;
|
||||||
add_scenes(&mut app, self.scenes)?;
|
add_scenes(&mut app, self.scenes)?;
|
||||||
Ok(app)
|
Ok(app)
|
||||||
})?)?;
|
})?;
|
||||||
Ok(())
|
engine.run(&state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@ pub struct GrooveboxCli {
|
||||||
impl GrooveboxCli {
|
impl GrooveboxCli {
|
||||||
fn run (&self) -> Usually<()> {
|
fn run (&self) -> Usually<()> {
|
||||||
let name = self.name.as_deref().unwrap_or("tek_groovebox");
|
let name = self.name.as_deref().unwrap_or("tek_groovebox");
|
||||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
let engine = Tui::new()?;
|
||||||
|
let state = JackConnection::new(name)?.activate_with(|jack|{
|
||||||
let app = tek::Groovebox::new(
|
let app = tek::Groovebox::new(
|
||||||
jack,
|
jack,
|
||||||
&self.midi_from.as_slice(),
|
&self.midi_from.as_slice(),
|
||||||
|
|
@ -58,8 +59,8 @@ impl GrooveboxCli {
|
||||||
})?
|
})?
|
||||||
}
|
}
|
||||||
Ok(app)
|
Ok(app)
|
||||||
})?)?;
|
})?;
|
||||||
Ok(())
|
engine.run(&state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,9 @@ pub fn main () -> Usually<()> { SamplerCli::parse().run() }
|
||||||
}
|
}
|
||||||
impl SamplerCli {
|
impl SamplerCli {
|
||||||
fn run (&self) -> Usually<()> {
|
fn run (&self) -> Usually<()> {
|
||||||
let name = self.name.as_deref().unwrap_or("tek_sampler");
|
let name = self.name.as_deref().unwrap_or("tek_sampler");
|
||||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
let engine = Tui::new()?;
|
||||||
|
let state = JackConnection::new(name)?.activate_with(|jack|{
|
||||||
Ok(tek::SamplerTui {
|
Ok(tek::SamplerTui {
|
||||||
cursor: (0, 0),
|
cursor: (0, 0),
|
||||||
editing: None,
|
editing: None,
|
||||||
|
|
@ -41,7 +42,7 @@ impl SamplerCli {
|
||||||
&[&self.l_to.as_slice(), &self.r_to.as_slice()],
|
&[&self.l_to.as_slice(), &self.r_to.as_slice()],
|
||||||
)?,
|
)?,
|
||||||
})
|
})
|
||||||
})?)?;
|
})?;
|
||||||
Ok(())
|
engine.run(&state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,8 +24,9 @@ pub struct SequencerCli {
|
||||||
|
|
||||||
impl SequencerCli {
|
impl SequencerCli {
|
||||||
fn run (&self) -> Usually<()> {
|
fn run (&self) -> Usually<()> {
|
||||||
let name = self.name.as_deref().unwrap_or("tek_sequencer");
|
let name = self.name.as_deref().unwrap_or("tek_sequencer");
|
||||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
let engine = Tui::new()?;
|
||||||
|
let state = JackConnection::new(name)?.activate_with(|jack|{
|
||||||
let mut app = SequencerTui::try_from(jack)?;
|
let mut app = SequencerTui::try_from(jack)?;
|
||||||
let jack = jack.read().unwrap();
|
let jack = jack.read().unwrap();
|
||||||
let midi_in = jack.register_port("i", MidiIn::default())?;
|
let midi_in = jack.register_port("i", MidiIn::default())?;
|
||||||
|
|
@ -35,8 +36,8 @@ impl SequencerCli {
|
||||||
app.player.midi_ins.push(midi_in);
|
app.player.midi_ins.push(midi_in);
|
||||||
app.player.midi_outs.push(midi_out);
|
app.player.midi_outs.push(midi_out);
|
||||||
Ok(app)
|
Ok(app)
|
||||||
})?)?;
|
})?;
|
||||||
Ok(())
|
engine.run(&state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,9 @@ include!("./lib.rs");
|
||||||
|
|
||||||
/// Application entrypoint.
|
/// Application entrypoint.
|
||||||
pub fn main () -> Usually<()> {
|
pub fn main () -> Usually<()> {
|
||||||
let name = "tek_transport";
|
let name = "tek_transport";
|
||||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
let engine = Tui::new()?;
|
||||||
TransportTui::try_from(jack)
|
let state = JackConnection::new(name)?
|
||||||
})?)?;
|
.activate_with(|jack|TransportTui::try_from(jack))?;
|
||||||
Ok(())
|
engine.run(&state)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
#[allow(unused_imports)] use std::sync::Arc;
|
#[allow(unused_imports)] use std::sync::Arc;
|
||||||
#[allow(unused_imports)] use clap::{self, Parser};
|
#[allow(unused_imports)] use clap::{self, Parser};
|
||||||
#[allow(unused_imports)] use tek::{*, jack::*};
|
#[allow(unused_imports)] use tek::{
|
||||||
|
*,
|
||||||
|
jack::*,
|
||||||
|
tek_layout::Measure,
|
||||||
|
tek_engine::{Usually, tui::{Tui, TuiRun, ratatui::prelude::Color}}
|
||||||
|
};
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
fn connect_from (jack: &JackConnection, input: &Port<MidiIn>, ports: &[String]) -> Usually<()> {
|
fn connect_from (jack: &JackConnection, input: &Port<MidiIn>, ports: &[String]) -> Usually<()> {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@
|
||||||
mod engine; pub use self::engine::*;
|
mod engine; pub use self::engine::*;
|
||||||
mod input; pub use self::input::*;
|
mod input; pub use self::input::*;
|
||||||
mod output; pub use self::output::*;
|
mod output; pub use self::output::*;
|
||||||
mod tui; pub use self::tui::*;
|
|
||||||
|
pub mod tui;
|
||||||
|
|
||||||
pub use std::error::Error;
|
pub use std::error::Error;
|
||||||
|
|
||||||
|
|
@ -58,6 +59,7 @@ pub type Perhaps<T> = Result<Option<T>, Box<dyn Error>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)] #[test] fn test_tui_engine () -> Usually<()> {
|
#[cfg(test)] #[test] fn test_tui_engine () -> Usually<()> {
|
||||||
|
use crate::tui::*;
|
||||||
use std::sync::{Arc, RwLock};
|
use std::sync::{Arc, RwLock};
|
||||||
struct TestComponent(String);
|
struct TestComponent(String);
|
||||||
impl Content<Tui> for TestComponent {
|
impl Content<Tui> for TestComponent {
|
||||||
|
|
|
||||||
|
|
@ -73,14 +73,14 @@ impl<'a, E: Engine, const N: usize> Iterator for CollectIterator<'a, E, N> {
|
||||||
type Item = &'a dyn Render<E>;
|
type Item = &'a dyn Render<E>;
|
||||||
fn next (&mut self) -> Option<Self::Item> {
|
fn next (&mut self) -> Option<Self::Item> {
|
||||||
match self.1 {
|
match self.1 {
|
||||||
Collect::Callback(callback) => {
|
Collect::Callback(_callback) => {
|
||||||
todo!()
|
todo!()
|
||||||
},
|
},
|
||||||
//Collection::Iterator(iterator) => {
|
//Collection::Iterator(iterator) => {
|
||||||
//iterator.next()
|
//iterator.next()
|
||||||
//},
|
//},
|
||||||
Collect::Array(array) => {
|
Collect::Array(array) => {
|
||||||
if let Some(item) = array.get(self.0) {
|
if let Some(_item) = array.get(self.0) {
|
||||||
self.0 += 1;
|
self.0 += 1;
|
||||||
//Some(item)
|
//Some(item)
|
||||||
None
|
None
|
||||||
|
|
@ -89,7 +89,7 @@ impl<'a, E: Engine, const N: usize> Iterator for CollectIterator<'a, E, N> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Collect::Slice(slice) => {
|
Collect::Slice(slice) => {
|
||||||
if let Some(item) = slice.get(self.0) {
|
if let Some(_item) = slice.get(self.0) {
|
||||||
self.0 += 1;
|
self.0 += 1;
|
||||||
//Some(item)
|
//Some(item)
|
||||||
None
|
None
|
||||||
|
|
@ -118,10 +118,10 @@ pub struct Reduce<E: Engine, T, I: Iterator<Item=T>, R: Render<E>, F: Fn(&dyn Re
|
||||||
);
|
);
|
||||||
|
|
||||||
impl<E: Engine, T, I: Iterator<Item=T>+Send+Sync, R: Render<E>, F: Fn(&dyn Render<E>, T)->R+Send+Sync> Render<E> for Reduce<E, T, I, R, F> {
|
impl<E: Engine, T, I: Iterator<Item=T>+Send+Sync, R: Render<E>, F: Fn(&dyn Render<E>, T)->R+Send+Sync> Render<E> for Reduce<E, T, I, R, F> {
|
||||||
fn min_size (&self, to: E::Size) -> Perhaps<E::Size> {
|
fn min_size (&self, _to: E::Size) -> Perhaps<E::Size> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
fn render (&self, to: &mut E::Output) -> Usually<()> {
|
fn render (&self, _to: &mut E::Output) -> Usually<()> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ where
|
||||||
West => {
|
West => {
|
||||||
let w: E::Unit = 0.into();
|
let w: E::Unit = 0.into();
|
||||||
let h: E::Unit = 0.into();
|
let h: E::Unit = 0.into();
|
||||||
(self.0)(&mut |component: &dyn Render<E>| {
|
(self.0)(&mut |_component: &dyn Render<E>| {
|
||||||
if w < to.w() {
|
if w < to.w() {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,13 @@
|
||||||
pub use ::tek_engine;
|
|
||||||
pub(crate) use ::tek_engine::*;
|
|
||||||
|
|
||||||
pub(crate) use std::marker::PhantomData;
|
|
||||||
pub(crate) use std::sync::atomic::Ordering::*;
|
|
||||||
|
|
||||||
mod collection; pub use self::collection::*;
|
mod collection; pub use self::collection::*;
|
||||||
mod direction; pub use self::direction::*;
|
mod direction; pub use self::direction::*;
|
||||||
mod logic; pub use self::logic::*;
|
mod logic; pub use self::logic::*;
|
||||||
mod space; pub use self::space::*;
|
mod space; pub use self::space::*;
|
||||||
mod transform; pub use self::transform::*;
|
mod transform; pub use self::transform::*;
|
||||||
|
|
||||||
|
pub use ::tek_engine;
|
||||||
|
pub(crate) use ::tek_engine::*;
|
||||||
|
pub(crate) use std::marker::PhantomData;
|
||||||
|
|
||||||
#[cfg(test)] #[test] fn test_layout () -> Usually<()> {
|
#[cfg(test)] #[test] fn test_layout () -> Usually<()> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -137,7 +137,11 @@ render!(<Tui>|self:Groovebox|{
|
||||||
Fill::xy(lay!([
|
Fill::xy(lay!([
|
||||||
&self.size,
|
&self.size,
|
||||||
Fill::xy(Align::s(Fixed::y(2, GrooveboxStatus::from(self)))),
|
Fill::xy(Align::s(Fixed::y(2, GrooveboxStatus::from(self)))),
|
||||||
Shrink::y(2, col!(![transport, selector, status]))
|
Shrink::y(2, col!(![
|
||||||
|
transport,
|
||||||
|
selector,
|
||||||
|
status
|
||||||
|
]))
|
||||||
]))
|
]))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -165,6 +169,14 @@ impl<'a, T: Render<Tui>> Content<Tui> for EditStatus<'a, T> {
|
||||||
]), &self.3))
|
]), &self.3))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
impl<'a, T: Render<Tui>> Render<Tui> for EditStatus<'a, T> {
|
||||||
|
fn min_size (&self, to: [u16;2]) -> Perhaps<[u16;2]> {
|
||||||
|
self.content().unwrap().min_size(to)
|
||||||
|
}
|
||||||
|
fn render (&self, to: &mut TuiOutput) -> Usually<()> {
|
||||||
|
self.content().unwrap().render(to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct GrooveboxSamples<'a>(&'a Groovebox);
|
struct GrooveboxSamples<'a>(&'a Groovebox);
|
||||||
render!(<Tui>|self: GrooveboxSamples<'a>|{
|
render!(<Tui>|self: GrooveboxSamples<'a>|{
|
||||||
|
|
|
||||||
24
src/lib.rs
24
src/lib.rs
|
|
@ -11,18 +11,20 @@ pub(crate) use ::tek_layout::{
|
||||||
Engine, Size, Area,
|
Engine, Size, Area,
|
||||||
Output, Content, Render, render,
|
Output, Content, Render, render,
|
||||||
Input, Handle, handle, kexp, key_pat, key_event_pat, key_event_expr,
|
Input, Handle, handle, kexp, key_pat, key_event_pat, key_event_expr,
|
||||||
Tui, TuiInput, TuiOutput,
|
tui::{
|
||||||
crossterm::{
|
Tui, TuiInput, TuiOutput,
|
||||||
self,
|
crossterm::{
|
||||||
event::{
|
self,
|
||||||
Event, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers,
|
event::{
|
||||||
KeyCode::{self, *},
|
Event, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers,
|
||||||
|
KeyCode::{self, *},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ratatui::{
|
||||||
|
self,
|
||||||
|
prelude::{Color, Style, Stylize, Buffer, Modifier},
|
||||||
|
buffer::Cell,
|
||||||
}
|
}
|
||||||
},
|
|
||||||
ratatui::{
|
|
||||||
self,
|
|
||||||
prelude::{Color, Style, Stylize, Buffer, Modifier},
|
|
||||||
buffer::Cell,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue