chore: remove dead code

This commit is contained in:
🪞👃🪞 2024-07-12 15:44:19 +03:00
parent 145827913a
commit 0cc8d88e5f
7 changed files with 20 additions and 61 deletions

View file

@ -64,8 +64,6 @@ pub const KEYMAP_FOCUS: &'static [KeyBinding<App>] = keymap!(App {
});
pub const KEYMAP: &'static [KeyBinding<App>] = 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<App>] = 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<App>] = 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<App>] = 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<App>] = 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<App>] = 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<App>] = 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<App>] = 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<bool> {
@ -169,31 +152,3 @@ fn focus_prev (app: &mut App) -> Usually<bool> {
app.section.prev();
Ok(true)
}
fn increment (_: &mut App) -> Usually<bool> {
Ok(false)
}
fn decrement (_: &mut App) -> Usually<bool> {
Ok(false)
}
fn delete (app: &mut App) -> Usually<bool> {
match app.section {
AppSection::Arranger => delete_track(app),
_ => Ok(false)
}
}
fn delete_track (app: &mut App) -> Usually<bool> {
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<bool> { Ok(true) }

View file

@ -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;

View file

@ -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) {

View file

@ -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<bool> {
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;

View file

@ -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<Timebase>,
/// JACK transport handle.

View file

@ -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;

View file

@ -210,8 +210,7 @@ impl<'a> SequencerView<'a> {
fn horizontal_keys (&self, buf: &mut Buffer, area: Rect) -> Usually<Rect> {
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 {