mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
feat: run stub tek_chain
This commit is contained in:
parent
2a60808239
commit
c089e6cfa4
9 changed files with 60 additions and 38 deletions
|
|
@ -135,34 +135,6 @@ pub const KEYMAP_GLOBAL: &'static [KeyBinding<App>] = keymap!(App {
|
|||
}],
|
||||
});
|
||||
|
||||
/// Key bindings for chain section.
|
||||
pub const KEYMAP_CHAIN: &'static [KeyBinding<App>] = keymap!(App {
|
||||
[Up, NONE, "chain_cursor_up", "move cursor up", |_: &mut App| {
|
||||
Ok(true)
|
||||
}],
|
||||
[Down, NONE, "chain_cursor_down", "move cursor down", |_: &mut App| {
|
||||
Ok(true)
|
||||
}],
|
||||
[Left, NONE, "chain_cursor_left", "move cursor left", |app: &mut App| {
|
||||
if let Some(track) = app.arranger.track_mut() {
|
||||
track.device = track.device.saturating_sub(1);
|
||||
return Ok(true)
|
||||
}
|
||||
Ok(false)
|
||||
}],
|
||||
[Right, NONE, "chain_cursor_right", "move cursor right", |app: &mut App| {
|
||||
if let Some(track) = app.arranger.track_mut() {
|
||||
track.device = (track.device + 1).min(track.devices.len().saturating_sub(1));
|
||||
return Ok(true)
|
||||
}
|
||||
Ok(false)
|
||||
}],
|
||||
[Char('`'), NONE, "chain_mode_switch", "switch the display mode", |app: &mut App| {
|
||||
app.chain_mode = !app.chain_mode;
|
||||
Ok(true)
|
||||
}],
|
||||
});
|
||||
|
||||
/// Generic key bindings for views that support focus.
|
||||
pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
|
||||
[Char(';'), NONE, "command", "open command palette", |_: &mut App| {
|
||||
|
|
|
|||
|
|
@ -6,3 +6,10 @@ version = "0.1.0"
|
|||
[dependencies]
|
||||
tek_core = { path = "../tek_core" }
|
||||
tek_jack = { path = "../tek_jack" }
|
||||
|
||||
[lib]
|
||||
path = "src/lib.rs"
|
||||
|
||||
[[bin]]
|
||||
name = "tek_chain"
|
||||
path = "src/main.rs"
|
||||
|
|
|
|||
|
|
@ -10,6 +10,15 @@ pub struct Chain {
|
|||
pub device: usize,
|
||||
}
|
||||
|
||||
handle!(Chain |self, event| handle_keymap(self, event, KEYMAP_CHAIN));
|
||||
|
||||
render!(Chain |self, buf, area| ChainView {
|
||||
chain: Some(&self),
|
||||
direction: tek_core::Direction::Right,
|
||||
focused: true,
|
||||
entered: true,
|
||||
}.render(buf, area));
|
||||
|
||||
impl Chain {
|
||||
pub fn new (name: &str) -> Usually<Self> {
|
||||
Ok(Self {
|
||||
|
|
@ -36,7 +45,7 @@ impl Chain {
|
|||
//}
|
||||
//Ok(())
|
||||
//}
|
||||
//pub fn connect_last_device (&self, app: &App) -> Usually<()> {
|
||||
//pub fn connect_last_device (&self, app: &Chain) -> Usually<()> {
|
||||
//Ok(match self.devices.get(self.devices.len().saturating_sub(1)) {
|
||||
//Some(device) => {
|
||||
//app.audio_out(0).map(|left|device.connect_audio_out(0, &left)).transpose()?;
|
||||
|
|
@ -48,3 +57,30 @@ impl Chain {
|
|||
//}
|
||||
}
|
||||
|
||||
/// Key bindings for chain section.
|
||||
pub const KEYMAP_CHAIN: &'static [KeyBinding<Chain>] = keymap!(Chain {
|
||||
[Up, NONE, "chain_cursor_up", "move cursor up", |_: &mut Chain| {
|
||||
Ok(true)
|
||||
}],
|
||||
[Down, NONE, "chain_cursor_down", "move cursor down", |_: &mut Chain| {
|
||||
Ok(true)
|
||||
}],
|
||||
[Left, NONE, "chain_cursor_left", "move cursor left", |app: &mut Chain| {
|
||||
//if let Some(track) = app.arranger.track_mut() {
|
||||
//track.device = track.device.saturating_sub(1);
|
||||
//return Ok(true)
|
||||
//}
|
||||
Ok(false)
|
||||
}],
|
||||
[Right, NONE, "chain_cursor_right", "move cursor right", |app: &mut Chain| {
|
||||
//if let Some(track) = app.arranger.track_mut() {
|
||||
//track.device = (track.device + 1).min(track.devices.len().saturating_sub(1));
|
||||
//return Ok(true)
|
||||
//}
|
||||
Ok(false)
|
||||
}],
|
||||
[Char('`'), NONE, "chain_mode_switch", "switch the display mode", |app: &mut Chain| {
|
||||
//app.chain_mode = !app.chain_mode;
|
||||
Ok(true)
|
||||
}],
|
||||
});
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ impl<'a> Render for ChainView<'a> {
|
|||
Style::default().dim()
|
||||
})
|
||||
.render_areas(buf, area)?;
|
||||
if self.focused && self.entered {
|
||||
if self.focused && self.entered && areas.len() > 0 {
|
||||
Corners(Style::default().green().not_dim()).draw(buf, areas[0])?;
|
||||
}
|
||||
Ok(area)
|
||||
|
|
|
|||
|
|
@ -2,7 +2,4 @@ pub(crate) use tek_core::*;
|
|||
pub(crate) use tek_core::ratatui::prelude::*;
|
||||
pub(crate) use tek_jack::*;
|
||||
pub(crate) use std::sync::RwLockWriteGuard;
|
||||
submod! {
|
||||
chain
|
||||
chain_view
|
||||
}
|
||||
submod! { chain chain_view }
|
||||
|
|
|
|||
9
crates/tek_chain/src/main.rs
Normal file
9
crates/tek_chain/src/main.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
pub(crate) use tek_core::*;
|
||||
pub(crate) use tek_core::ratatui::prelude::*;
|
||||
pub(crate) use tek_jack::*;
|
||||
pub(crate) use std::sync::RwLockWriteGuard;
|
||||
submod! { chain chain_view }
|
||||
pub fn main () -> Usually<()> {
|
||||
tek_core::run(Arc::new(RwLock::new(crate::Chain::new("todo")?)))?;
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -1,13 +1,14 @@
|
|||
pub use ratatui;
|
||||
pub use crossterm;
|
||||
pub use midly;
|
||||
pub use std::sync::{Arc, Mutex, RwLock};
|
||||
pub use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};
|
||||
|
||||
pub(crate) use std::error::Error;
|
||||
pub(crate) use std::io::{stdout};
|
||||
pub(crate) use std::thread::{spawn, JoinHandle};
|
||||
pub(crate) use std::time::Duration;
|
||||
pub(crate) use std::sync::atomic::{Ordering, AtomicBool};
|
||||
pub(crate) use std::sync::{Arc, Mutex, RwLock};
|
||||
//, LockResult, RwLockReadGuard, RwLockWriteGuard};
|
||||
//pub(crate) use std::path::PathBuf;
|
||||
//pub(crate) use std::fs::read_dir;
|
||||
|
|
@ -17,7 +18,6 @@ pub(crate) use std::sync::{Arc, Mutex, RwLock};
|
|||
//pub(crate) use microxdg::XdgApp;
|
||||
//pub(crate) use midly::{MidiMessage, live::LiveEvent, num::u7};
|
||||
pub(crate) use crossterm::{ExecutableCommand};
|
||||
pub(crate) use crossterm::event::{Event, KeyEvent, KeyCode, KeyModifiers};
|
||||
use better_panic::{Settings, Verbosity};
|
||||
use crossterm::terminal::{
|
||||
EnterAlternateScreen, LeaveAlternateScreen,
|
||||
|
|
|
|||
|
|
@ -123,8 +123,9 @@ impl Arranger {
|
|||
}
|
||||
|
||||
fn show_phrase (&mut self) -> Usually<()> {
|
||||
let phrase = self.phrase();
|
||||
self.sequencer.show(phrase)
|
||||
unimplemented!()
|
||||
//let phrase = self.phrase();
|
||||
//self.sequencer.show(phrase)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue