mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-05-04 23:40:14 +02:00
big flat pt.13: fixed warnings, let's see what it has in store
This commit is contained in:
parent
e21ef1af94
commit
5bc3517dde
bin
engine/src
layout/src
src
|
@ -30,15 +30,16 @@ impl ArrangerCli {
|
|||
/// Run the arranger TUI from CLI arguments.
|
||||
fn run (&self) -> Usually<()> {
|
||||
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 jack = jack.read().unwrap();
|
||||
app.color = ItemPalette::random();
|
||||
add_tracks(&jack, &mut app, self)?;
|
||||
add_scenes(&mut app, self.scenes)?;
|
||||
Ok(app)
|
||||
})?)?;
|
||||
Ok(())
|
||||
})?;
|
||||
engine.run(&state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,8 @@ pub struct GrooveboxCli {
|
|||
impl GrooveboxCli {
|
||||
fn run (&self) -> Usually<()> {
|
||||
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(
|
||||
jack,
|
||||
&self.midi_from.as_slice(),
|
||||
|
@ -58,8 +59,8 @@ impl GrooveboxCli {
|
|||
})?
|
||||
}
|
||||
Ok(app)
|
||||
})?)?;
|
||||
Ok(())
|
||||
})?;
|
||||
engine.run(&state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,9 @@ pub fn main () -> Usually<()> { SamplerCli::parse().run() }
|
|||
}
|
||||
impl SamplerCli {
|
||||
fn run (&self) -> Usually<()> {
|
||||
let name = self.name.as_deref().unwrap_or("tek_sampler");
|
||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
||||
let name = self.name.as_deref().unwrap_or("tek_sampler");
|
||||
let engine = Tui::new()?;
|
||||
let state = JackConnection::new(name)?.activate_with(|jack|{
|
||||
Ok(tek::SamplerTui {
|
||||
cursor: (0, 0),
|
||||
editing: None,
|
||||
|
@ -41,7 +42,7 @@ impl SamplerCli {
|
|||
&[&self.l_to.as_slice(), &self.r_to.as_slice()],
|
||||
)?,
|
||||
})
|
||||
})?)?;
|
||||
Ok(())
|
||||
})?;
|
||||
engine.run(&state)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,8 +24,9 @@ pub struct SequencerCli {
|
|||
|
||||
impl SequencerCli {
|
||||
fn run (&self) -> Usually<()> {
|
||||
let name = self.name.as_deref().unwrap_or("tek_sequencer");
|
||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
||||
let name = self.name.as_deref().unwrap_or("tek_sequencer");
|
||||
let engine = Tui::new()?;
|
||||
let state = JackConnection::new(name)?.activate_with(|jack|{
|
||||
let mut app = SequencerTui::try_from(jack)?;
|
||||
let jack = jack.read().unwrap();
|
||||
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_outs.push(midi_out);
|
||||
Ok(app)
|
||||
})?)?;
|
||||
Ok(())
|
||||
})?;
|
||||
engine.run(&state)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@ include!("./lib.rs");
|
|||
|
||||
/// Application entrypoint.
|
||||
pub fn main () -> Usually<()> {
|
||||
let name = "tek_transport";
|
||||
Tui::run(JackConnection::new(name)?.activate_with(|jack|{
|
||||
TransportTui::try_from(jack)
|
||||
})?)?;
|
||||
Ok(())
|
||||
let name = "tek_transport";
|
||||
let engine = Tui::new()?;
|
||||
let state = JackConnection::new(name)?
|
||||
.activate_with(|jack|TransportTui::try_from(jack))?;
|
||||
engine.run(&state)
|
||||
}
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
#[allow(unused_imports)] use std::sync::Arc;
|
||||
#[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)]
|
||||
fn connect_from (jack: &JackConnection, input: &Port<MidiIn>, ports: &[String]) -> Usually<()> {
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
mod engine; pub use self::engine::*;
|
||||
mod input; pub use self::input::*;
|
||||
mod output; pub use self::output::*;
|
||||
mod tui; pub use self::tui::*;
|
||||
|
||||
pub mod tui;
|
||||
|
||||
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<()> {
|
||||
use crate::tui::*;
|
||||
use std::sync::{Arc, RwLock};
|
||||
struct TestComponent(String);
|
||||
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>;
|
||||
fn next (&mut self) -> Option<Self::Item> {
|
||||
match self.1 {
|
||||
Collect::Callback(callback) => {
|
||||
Collect::Callback(_callback) => {
|
||||
todo!()
|
||||
},
|
||||
//Collection::Iterator(iterator) => {
|
||||
//iterator.next()
|
||||
//},
|
||||
Collect::Array(array) => {
|
||||
if let Some(item) = array.get(self.0) {
|
||||
if let Some(_item) = array.get(self.0) {
|
||||
self.0 += 1;
|
||||
//Some(item)
|
||||
None
|
||||
|
@ -89,7 +89,7 @@ impl<'a, E: Engine, const N: usize> Iterator for CollectIterator<'a, E, N> {
|
|||
}
|
||||
}
|
||||
Collect::Slice(slice) => {
|
||||
if let Some(item) = slice.get(self.0) {
|
||||
if let Some(_item) = slice.get(self.0) {
|
||||
self.0 += 1;
|
||||
//Some(item)
|
||||
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> {
|
||||
fn min_size (&self, to: E::Size) -> Perhaps<E::Size> {
|
||||
fn min_size (&self, _to: E::Size) -> Perhaps<E::Size> {
|
||||
todo!()
|
||||
}
|
||||
fn render (&self, to: &mut E::Output) -> Usually<()> {
|
||||
fn render (&self, _to: &mut E::Output) -> Usually<()> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ where
|
|||
West => {
|
||||
let w: 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() {
|
||||
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 direction; pub use self::direction::*;
|
||||
mod logic; pub use self::logic::*;
|
||||
mod space; pub use self::space::*;
|
||||
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<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -137,7 +137,11 @@ render!(<Tui>|self:Groovebox|{
|
|||
Fill::xy(lay!([
|
||||
&self.size,
|
||||
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))
|
||||
}
|
||||
}
|
||||
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);
|
||||
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,
|
||||
Output, Content, Render, render,
|
||||
Input, Handle, handle, kexp, key_pat, key_event_pat, key_event_expr,
|
||||
Tui, TuiInput, TuiOutput,
|
||||
crossterm::{
|
||||
self,
|
||||
event::{
|
||||
Event, KeyEvent, KeyEventKind, KeyEventState, KeyModifiers,
|
||||
KeyCode::{self, *},
|
||||
tui::{
|
||||
Tui, TuiInput, TuiOutput,
|
||||
crossterm::{
|
||||
self,
|
||||
event::{
|
||||
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…
Reference in a new issue