mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
wip: let's figure out how edn keymaps will work
This commit is contained in:
parent
4ab08e48e5
commit
794d4210c6
33 changed files with 161 additions and 85 deletions
|
|
@ -1,20 +1,20 @@
|
|||
(:enter note/put)
|
||||
(:del note/del)
|
||||
(:comma note/dur/dec)
|
||||
(:period note/dur/inc)
|
||||
(:plus note/range/inc)
|
||||
(:underscore note/range/dec)
|
||||
(:up note/pos/inc)
|
||||
(:down note/pos/dec)
|
||||
(:left time/pos/dec)
|
||||
(:right time/pos/inc)
|
||||
(:z time/zoom/lock)
|
||||
(:equal time/zoom/in)
|
||||
(:minus time/zoom/out)
|
||||
(:space clock/toggle)
|
||||
(:shift-space clock/toggle/zero)
|
||||
(:u undo)
|
||||
(:r redo)
|
||||
(:tab compact)
|
||||
(:q enqueue)
|
||||
(:0 stop)
|
||||
(:enter add :false)
|
||||
(:shift-enter add :true)
|
||||
(:del del :false)
|
||||
(:shift-del del :true)
|
||||
(:comma note/length :prev-note-length)
|
||||
(:period note/length :next-note-length)
|
||||
(:plus note/range :next-note-range)
|
||||
(:underscore note/range :prev-note-range)
|
||||
(:up note/point :next-note-point)
|
||||
(:down note/point :prev-note-point)
|
||||
(:left time/point :next-time-point)
|
||||
(:right time/point :prev-time-point)
|
||||
(:z time/lock :next-time-lock)
|
||||
(:equal time/zoom :next-time-zoom)
|
||||
(:minus time/zoom :prev-time-zoom)
|
||||
(:space clock/play :play-current)
|
||||
(:shift-space clock/play :play-start)
|
||||
(:u history :history-prev)
|
||||
(:r history :history-next)
|
||||
(:tab compact :next-compact)
|
||||
|
|
|
|||
|
|
@ -1 +1,13 @@
|
|||
;TODO
|
||||
(:n clip/rename/begin)
|
||||
(:t clip/length/begin)
|
||||
(:m clip/import/begin)
|
||||
(:x clip/export/begin)
|
||||
(:c clip/color/random)
|
||||
(:bracket-open clip/select/prev)
|
||||
(:bracket-close clip/select/next)
|
||||
(:lt clip/move/prev)
|
||||
(:gt clip/move/next)
|
||||
(:del clip/delete)
|
||||
(:shift-a clip/add)
|
||||
(:i clip/insert)
|
||||
(:d clip/duplicate)
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ pub trait HasMidiClip {
|
|||
}
|
||||
|
||||
/// A MIDI sequence.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Default)]
|
||||
pub struct MidiClip {
|
||||
pub uuid: uuid::Uuid,
|
||||
/// Name of clip
|
||||
|
|
@ -83,10 +83,7 @@ impl MidiClip {
|
|||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MidiClip {
|
||||
fn default () -> Self {
|
||||
pub fn stop_all () -> Self {
|
||||
Self::new(
|
||||
"Stop",
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -1,8 +1,23 @@
|
|||
use crate::*;
|
||||
use self::MidiEditCommand::*;
|
||||
use KeyCode::*;
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum MidiEditCommand {
|
||||
impl EdnCommand<MidiEditor> for MidiEditCommand {
|
||||
fn from_edn <'a> (state: &MidiEditor, head: &EdnItem<&str>, tail: &'a [EdnItem<String>]) -> Self {
|
||||
use EdnItem::*;
|
||||
match (head, tail) {
|
||||
(Key("note/put"), [a]) => Self::PutNote,
|
||||
(Key("note/del"), [a]) => Self::AppendNote,
|
||||
(Key("note/dur"), [a]) => Self::AppendNote,
|
||||
(Key("note/range"), [a]) => Self::AppendNote,
|
||||
(Key("note/pos"), [a]) => Self::AppendNote,
|
||||
(Key("time/pos"), [a]) => Self::AppendNote,
|
||||
(Key("time/zoom"), [a]) => Self::AppendNote,
|
||||
(Key("time/lock"), [a]) => Self::AppendNote,
|
||||
_ => todo!()
|
||||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug)] pub enum MidiEditCommand {
|
||||
// TODO: 1-9 seek markers that by default start every 8th of the clip
|
||||
AppendNote,
|
||||
PutNote,
|
||||
|
|
@ -70,8 +85,3 @@ impl Command<MidiEditor> for MidiEditCommand {
|
|||
Ok(None)
|
||||
}
|
||||
}
|
||||
impl EdnCommand<MidiEditor> for MidiEditCommand {
|
||||
fn from_edn <'a> (state: &MidiEditor, head: &EdnItem<&str>, tail: &'a [EdnItem<String>]) -> Self {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -135,34 +135,3 @@ impl ClipLengthFocus {
|
|||
*self = match self { Self::Bar => Self::Tick, Self::Beat => Self::Bar, Self::Tick => Self::Beat, }
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum ClipRenameCommand {
|
||||
Begin,
|
||||
Cancel,
|
||||
Confirm,
|
||||
Set(Arc<str>),
|
||||
}
|
||||
impl Command<PoolModel> for ClipRenameCommand {
|
||||
fn execute (self, state: &mut PoolModel) -> Perhaps<Self> {
|
||||
use ClipRenameCommand::*;
|
||||
match state.clips_mode_mut().clone() {
|
||||
Some(PoolMode::Rename(clip, ref mut old_name)) => match self {
|
||||
Set(s) => {
|
||||
state.clips()[clip].write().unwrap().name = s;
|
||||
return Ok(Some(Self::Set(old_name.clone().into())))
|
||||
},
|
||||
Confirm => {
|
||||
let old_name = old_name.clone();
|
||||
*state.clips_mode_mut() = None;
|
||||
return Ok(Some(Self::Set(old_name)))
|
||||
},
|
||||
Cancel => {
|
||||
state.clips()[clip].write().unwrap().name = old_name.clone().into();
|
||||
},
|
||||
_ => unreachable!()
|
||||
},
|
||||
_ => unreachable!()
|
||||
};
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -317,7 +317,6 @@ command!(|self: ClipLengthCommand,state:PoolModel|{
|
|||
};
|
||||
None
|
||||
});
|
||||
|
||||
input_to_command!(ClipLengthCommand: |state: PoolModel, input: Event|{
|
||||
if let Some(PoolMode::Length(_, length, _)) = state.clips_mode() {
|
||||
match input {
|
||||
|
|
@ -333,10 +332,6 @@ input_to_command!(ClipLengthCommand: |state: PoolModel, input: Event|{
|
|||
unreachable!()
|
||||
}
|
||||
});
|
||||
use crate::*;
|
||||
use super::*;
|
||||
|
||||
|
||||
impl InputToCommand<Event, PoolModel> for ClipRenameCommand {
|
||||
fn input_to_command (state: &PoolModel, input: &Event) -> Option<Self> {
|
||||
use KeyCode::{Char, Backspace, Enter, Esc};
|
||||
|
|
@ -361,3 +356,34 @@ impl InputToCommand<Event, PoolModel> for ClipRenameCommand {
|
|||
}
|
||||
}
|
||||
}
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum ClipRenameCommand {
|
||||
Begin,
|
||||
Cancel,
|
||||
Confirm,
|
||||
Set(Arc<str>),
|
||||
}
|
||||
impl Command<PoolModel> for ClipRenameCommand {
|
||||
fn execute (self, state: &mut PoolModel) -> Perhaps<Self> {
|
||||
use ClipRenameCommand::*;
|
||||
match state.clips_mode_mut().clone() {
|
||||
Some(PoolMode::Rename(clip, ref mut old_name)) => match self {
|
||||
Set(s) => {
|
||||
state.clips()[clip].write().unwrap().name = s;
|
||||
return Ok(Some(Self::Set(old_name.clone().into())))
|
||||
},
|
||||
Confirm => {
|
||||
let old_name = old_name.clone();
|
||||
*state.clips_mode_mut() = None;
|
||||
return Ok(Some(Self::Set(old_name)))
|
||||
},
|
||||
Cancel => {
|
||||
state.clips()[clip].write().unwrap().name = old_name.clone().into();
|
||||
},
|
||||
_ => unreachable!()
|
||||
},
|
||||
_ => unreachable!()
|
||||
};
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue