diff --git a/src/control.rs b/src/control.rs index 14450e7d..e1063c8c 100644 --- a/src/control.rs +++ b/src/control.rs @@ -64,8 +64,6 @@ pub const KEYMAP_FOCUS: &'static [KeyBinding] = keymap!(App { }); pub const KEYMAP: &'static [KeyBinding] = keymap!(App { - //[F(1), NONE, "help_toggle", "toggle help", |_: &mut App| {Ok(true)}], - [Up, NONE, "focus_prev", "focus previous area", |app: &mut App|match app.track_cursor { 0 => {app.section = AppSection::Arranger;Ok(true)}, _ => focus_prev(app) @@ -74,7 +72,6 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { 0 => {app.section = AppSection::Chain;Ok(true)}, _ => focus_next(app) }], - [Char(' '), NONE, "play_toggle", "play or pause", |app: &mut App| { app.transport.toggle_play()?; Ok(true) @@ -91,7 +88,6 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { app.track_mut().map(|t|t.1.toggle_monitor()); Ok(true) }], - [Char('+'), NONE, "quant_inc", "quantize coarser", |app: &mut App| { app.transport.quant = next_note_length(app.transport.quant); Ok(true) @@ -100,7 +96,6 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { app.transport.quant = prev_note_length(app.transport.quant); Ok(true) }], - [Char('='), NONE, "zoom_in", "show fewer ticks per block", |app: &mut App| { app.seq_buf.time_zoom = prev_note_length(app.seq_buf.time_zoom); Ok(true) @@ -109,7 +104,6 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { app.seq_buf.time_zoom = next_note_length(app.seq_buf.time_zoom); Ok(true) }], - [Char('x'), NONE, "extend", "double the current clip", |app: &mut App| { if let Some(phrase) = app.phrase_mut() { let mut notes = phrase.notes.clone(); @@ -119,7 +113,6 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { } Ok(true) }], - [Char('l'), NONE, "loop_toggle", "toggle looping", |_app: &mut App| { // TODO: This toggles the loop flag for the clip under the cursor. Ok(true) @@ -133,15 +126,13 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { Ok(true) }], [Char('{'), NONE, "loop_end_dec", "move loop end back", |_app: &mut App| { - // TODOO: This moves the loop end to the previous quant. + // TODO: This moves the loop end to the previous quant. Ok(true) }], [Char('}'), NONE, "loop_end_inc", "move loop end forward", |_app: &mut App| { // TODO: This moves the loop end to the next quant. Ok(true) }], - - [Char('a'), CONTROL, "scene_add", "add a new scene", |app: &mut App| { app.add_scene(None)?; Ok(true) @@ -150,14 +141,6 @@ pub const KEYMAP: &'static [KeyBinding] = keymap!(App { app.add_track(None)?; Ok(true) }], - - [Char('.'), NONE, "cursor_inc", "increment value", increment], - [Char(','), NONE, "cursor_dec", "decrement value", decrement], - [Delete, CONTROL, "cursor_delete", "delete item at cursor", delete], - [Char('d'), CONTROL, "cursor_duplicate", "duplicate scene or track", duplicate], - - //[Char('r'), CONTROL, "rename", "rename current element", rename], -// [Char('s'), NONE, "stop_and_rewind", "Stop and rewind", stop_and_rewind], }); fn focus_next (app: &mut App) -> Usually { @@ -169,31 +152,3 @@ fn focus_prev (app: &mut App) -> Usually { app.section.prev(); Ok(true) } - -fn increment (_: &mut App) -> Usually { - Ok(false) -} - - -fn decrement (_: &mut App) -> Usually { - Ok(false) -} - -fn delete (app: &mut App) -> Usually { - match app.section { - AppSection::Arranger => delete_track(app), - _ => Ok(false) - } -} - -fn delete_track (app: &mut App) -> Usually { - if app.tracks.len() > 0 { - let track = app.tracks.remove(app.track_cursor); - app.track_cursor = app.track_cursor.saturating_sub(1); - track.midi_out.map(|port|app.client().unregister_port(port)).transpose()?; - return Ok(true) - } - Ok(false) -} - -fn duplicate (_: &mut App) -> Usually { Ok(true) } diff --git a/src/core.rs b/src/core.rs index aebcc8a2..8e7a8eba 100644 --- a/src/core.rs +++ b/src/core.rs @@ -4,12 +4,8 @@ pub(crate) use std::io::{stdout}; pub(crate) use std::thread::{spawn, JoinHandle}; pub(crate) use std::time::Duration; pub(crate) use std::collections::BTreeMap; -pub(crate) use std::sync::atomic::{Ordering, AtomicBool, AtomicUsize}; -pub(crate) use std::sync::{ - Arc, - Mutex, MutexGuard, - RwLock, LockResult, TryLockResult, RwLockReadGuard, RwLockWriteGuard -}; +pub(crate) use std::sync::atomic::{Ordering, AtomicBool}; +pub(crate) use std::sync::{Arc, Mutex, RwLock, LockResult, RwLockReadGuard, RwLockWriteGuard}; // Non-stdlib dependencies: pub(crate) use microxdg::XdgApp; diff --git a/src/core/render.rs b/src/core/render.rs index f8a80d82..50a19896 100644 --- a/src/core/render.rs +++ b/src/core/render.rs @@ -2,7 +2,7 @@ use crate::core::*; pub(crate) use ratatui::prelude::CrosstermBackend; pub(crate) use ratatui::style::{Stylize, Style, Color}; pub(crate) use ratatui::layout::Rect; -pub(crate) use ratatui::buffer::{Buffer, Cell}; +pub(crate) use ratatui::buffer::Buffer; use ratatui::widgets::WidgetRef; pub fn fill_fg (buf: &mut Buffer, area: Rect, color: Color) { diff --git a/src/model/track.rs b/src/model/track.rs index 4edf49bd..fb3ae537 100644 --- a/src/model/track.rs +++ b/src/model/track.rs @@ -18,6 +18,15 @@ impl App { self.track_cursor = self.tracks.len(); Ok(&mut self.tracks[self.track_cursor - 1]) } + pub fn del_track (&mut self) -> Usually { + if self.tracks.len() > 0 { + let track = self.tracks.remove(self.track_cursor); + self.track_cursor = self.track_cursor.saturating_sub(1); + track.midi_out.map(|port|self.client().unregister_port(port)).transpose()?; + return Ok(true) + } + Ok(false) + } pub fn track (&self) -> Option<(usize, &Track)> { match self.track_cursor { 0 => None, _ => { let id = self.track_cursor as usize - 1; diff --git a/src/model/transport.rs b/src/model/transport.rs index 0305cb69..fd16ad44 100644 --- a/src/model/transport.rs +++ b/src/model/transport.rs @@ -1,9 +1,9 @@ -use crate::{core::*,view::*,model::{App, AppSection}}; +use crate::core::*; pub struct TransportToolbar { - mode: bool, - pub focused: bool, - pub entered: bool, + pub mode: bool, + pub focused: bool, + pub entered: bool, /// Current sample rate, tempo, and PPQ. pub timebase: Arc, /// JACK transport handle. diff --git a/src/view/arranger.rs b/src/view/arranger.rs index 44a78f22..316bfabb 100644 --- a/src/view/arranger.rs +++ b/src/view/arranger.rs @@ -228,7 +228,7 @@ impl<'a> ArrangerView<'a> { " DEL ".blit(buf, area.x, area.y + y, style2)?; } else if y % 2 == 1 { let index = y as usize / 2; - if let Some(track) = self.tracks.get(index) { + if let Some(_) = self.tracks.get(index) { " DEL ".blit(buf, area.x, area.y + y, style4)?; } else { area.height = y; @@ -247,7 +247,7 @@ impl<'a> ArrangerView<'a> { " GAIN ".blit(buf, area.x, area.y + y, style2)?; } else if y % 2 == 1 { let index = y as usize / 2; - if let Some(track) = self.tracks.get(index) { + if let Some(_) = self.tracks.get(index) { " +0.0 ".blit(buf, area.x, area.y + y, style4)?; } else { area.height = y; diff --git a/src/view/sequencer.rs b/src/view/sequencer.rs index 2dbd16eb..caa19555 100644 --- a/src/view/sequencer.rs +++ b/src/view/sequencer.rs @@ -210,8 +210,7 @@ impl<'a> SequencerView<'a> { fn horizontal_keys (&self, buf: &mut Buffer, area: Rect) -> Usually { let note0 = self.note_start; let not_dim = Style::default().not_dim(); - let black = not_dim.black(); - let Rect { x, y, width, height } = area; + let Rect { x, y, height, .. } = area; let height = height.min(128); let h = height.saturating_sub(3); for index in 0..h {