mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
fixed up some parsing and removed some edn mentions
This commit is contained in:
parent
5e7b867aba
commit
452bdf9598
15 changed files with 290 additions and 292 deletions
|
|
@ -184,7 +184,7 @@ impl MidiViewer for MidiEditor {
|
|||
fn clip_mut (&mut self) -> &mut Option<Arc<RwLock<MidiClip>>> { self.mode.clip_mut() }
|
||||
fn set_clip (&mut self, p: Option<&Arc<RwLock<MidiClip>>>) { self.mode.set_clip(p) }
|
||||
}
|
||||
edn_command!(MidiEditCommand: |state: MidiEditor| {
|
||||
atom_command!(MidiEditCommand: |state: MidiEditor| {
|
||||
("note/put" [_a: bool] Self::PutNote)
|
||||
("note/del" [_a: bool] Self::PutNote)
|
||||
("note/pos" [a: usize] Self::SetNoteCursor(a.expect("no note cursor")))
|
||||
|
|
@ -208,14 +208,14 @@ edn_command!(MidiEditCommand: |state: MidiEditor| {
|
|||
Show(Option<Arc<RwLock<MidiClip>>>),
|
||||
}
|
||||
impl MidiEditCommand {
|
||||
fn from_tui_event (state: &MidiEditor, input: &impl EdnInput) -> Usually<Option<Self>> {
|
||||
use EdnItem::*;
|
||||
let edns = EdnItem::read_all(KEYS_EDIT)?;
|
||||
for item in edns.iter() {
|
||||
if let Exp(e) = item {
|
||||
fn from_tui_event (state: &MidiEditor, input: &impl AtomInput) -> Usually<Option<Self>> {
|
||||
use AtomItem::*;
|
||||
let atoms = AtomItem::read_all(KEYS_EDIT)?;
|
||||
for atom in atoms.iter() {
|
||||
if let Exp(e) = atom {
|
||||
match e.as_slice() {
|
||||
[Sym(key), command, args @ ..] if input.matches_edn(key) => {
|
||||
return Ok(MidiEditCommand::from_edn(state, command, args))
|
||||
[Sym(key), command, args @ ..] if input.matches_atom(key) => {
|
||||
return Ok(MidiEditCommand::from_atom(state, command, args))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -190,19 +190,19 @@ content!(TuiOut: |self: ClipLength| {
|
|||
}
|
||||
});
|
||||
impl PoolCommand {
|
||||
pub fn from_tui_event (state: &MidiPool, input: &impl EdnInput) -> Usually<Option<Self>> {
|
||||
use EdnItem::*;
|
||||
let edns: Vec<EdnItem<_>> = EdnItem::read_all(match state.mode() {
|
||||
pub fn from_tui_event (state: &MidiPool, input: &impl AtomInput) -> Usually<Option<Self>> {
|
||||
use AtomItem::*;
|
||||
let atoms: Vec<AtomItem<_>> = AtomItem::read_all(match state.mode() {
|
||||
Some(PoolMode::Rename(..)) => KEYS_RENAME,
|
||||
Some(PoolMode::Length(..)) => KEYS_LENGTH,
|
||||
Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => KEYS_FILE,
|
||||
_ => KEYS_POOL
|
||||
})?;
|
||||
for item in edns {
|
||||
for item in atoms {
|
||||
match item {
|
||||
Exp(e) => match e.as_slice() {
|
||||
[Sym(key), command, args @ ..] if input.matches_edn(key) => {
|
||||
return Ok(PoolCommand::from_edn(state, command, args))
|
||||
[Sym(key), command, args @ ..] if input.matches_atom(key) => {
|
||||
return Ok(PoolCommand::from_atom(state, command, args))
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
|
@ -273,14 +273,14 @@ provide!(ItemColor: |self: MidiPool| {
|
|||
/// Update the contents of the clip pool
|
||||
Clip(PoolClipCommand),
|
||||
}
|
||||
edn_command!(PoolCommand: |state: MidiPool| {
|
||||
atom_command!(PoolCommand: |state: MidiPool| {
|
||||
("show" [a: bool] Self::Show(a.expect("no flag")))
|
||||
("select" [i: usize] Self::Select(i.expect("no index")))
|
||||
("rename" [a, ..b] ClipRenameCommand::from_edn(state, &a.to_ref(), b).map(Self::Rename).expect("invalid command"))
|
||||
("length" [a, ..b] ClipLengthCommand::from_edn(state, &a.to_ref(), b).map(Self::Length).expect("invalid command"))
|
||||
("import" [a, ..b] FileBrowserCommand::from_edn(state, &a.to_ref(), b).map(Self::Import).expect("invalid command"))
|
||||
("export" [a, ..b] FileBrowserCommand::from_edn(state, &a.to_ref(), b).map(Self::Export).expect("invalid command"))
|
||||
("clip" [a, ..b] PoolClipCommand::from_edn(state, &a.to_ref(), b).map(Self::Clip).expect("invalid command"))
|
||||
("rename" [a, ..b] ClipRenameCommand::from_atom(state, &a.to_ref(), b).map(Self::Rename).expect("invalid command"))
|
||||
("length" [a, ..b] ClipLengthCommand::from_atom(state, &a.to_ref(), b).map(Self::Length).expect("invalid command"))
|
||||
("import" [a, ..b] FileBrowserCommand::from_atom(state, &a.to_ref(), b).map(Self::Import).expect("invalid command"))
|
||||
("export" [a, ..b] FileBrowserCommand::from_atom(state, &a.to_ref(), b).map(Self::Export).expect("invalid command"))
|
||||
("clip" [a, ..b] PoolClipCommand::from_atom(state, &a.to_ref(), b).map(Self::Clip).expect("invalid command"))
|
||||
});
|
||||
command!(|self: PoolCommand, state: MidiPool|{
|
||||
use PoolCommand::*;
|
||||
|
|
@ -308,7 +308,7 @@ command!(|self: PoolCommand, state: MidiPool|{
|
|||
SetLength(usize, usize),
|
||||
SetColor(usize, ItemColor),
|
||||
}
|
||||
edn_command!(PoolClipCommand: |state: MidiPool| {
|
||||
atom_command!(PoolClipCommand: |state: MidiPool| {
|
||||
("add" [i: usize, c: MidiClip] Self::Add(i.expect("no index"), c.expect("no clip")))
|
||||
("delete" [i: usize] Self::Delete(i.expect("no index")))
|
||||
("swap" [a: usize, b: usize] Self::Swap(a.expect("no index"), b.expect("no index")))
|
||||
|
|
@ -389,7 +389,7 @@ impl<T: HasClips> Command<T> for PoolClipCommand {
|
|||
Confirm,
|
||||
Set(Arc<str>),
|
||||
}
|
||||
edn_command!(ClipRenameCommand: |state: MidiPool| {
|
||||
atom_command!(ClipRenameCommand: |state: MidiPool| {
|
||||
("begin" [] Self::Begin)
|
||||
("cancel" [] Self::Cancel)
|
||||
("confirm" [] Self::Confirm)
|
||||
|
|
@ -429,7 +429,7 @@ command!(|self: ClipRenameCommand, state: MidiPool|{
|
|||
Inc,
|
||||
Dec,
|
||||
}
|
||||
edn_command!(ClipLengthCommand: |state: MidiPool| {
|
||||
atom_command!(ClipLengthCommand: |state: MidiPool| {
|
||||
("begin" [] Self::Begin)
|
||||
("cancel" [] Self::Cancel)
|
||||
("next" [] Self::Next)
|
||||
|
|
@ -475,7 +475,7 @@ command!(|self: ClipLengthCommand, state: MidiPool|{
|
|||
}
|
||||
None
|
||||
});
|
||||
edn_command!(FileBrowserCommand: |state: MidiPool| {
|
||||
atom_command!(FileBrowserCommand: |state: MidiPool| {
|
||||
("begin" [] Self::Begin)
|
||||
("cancel" [] Self::Cancel)
|
||||
("confirm" [] Self::Confirm)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue