mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
remove Atom. almost there
This commit is contained in:
parent
dc7b713108
commit
cf1fd5b45a
20 changed files with 539 additions and 739 deletions
|
|
@ -1,4 +1,5 @@
|
|||
use crate::*;
|
||||
use Value::*;
|
||||
pub trait HasEditor {
|
||||
fn editor (&self) -> &Option<MidiEditor>;
|
||||
fn editor_mut (&mut self) -> &Option<MidiEditor>;
|
||||
|
|
@ -31,6 +32,7 @@ pub trait HasEditor {
|
|||
pub struct MidiEditor {
|
||||
pub mode: PianoHorizontal,
|
||||
pub size: Measure<TuiOut>,
|
||||
keys: TokenIter<'static>
|
||||
}
|
||||
has_size!(<TuiOut>|self: MidiEditor|&self.size);
|
||||
content!(TuiOut: |self: MidiEditor| {
|
||||
|
|
@ -90,6 +92,7 @@ impl Default for MidiEditor {
|
|||
Self {
|
||||
mode: PianoHorizontal::new(None),
|
||||
size: Measure::new(),
|
||||
keys: TokenIter(KEYS_EDIT),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -207,27 +210,8 @@ atom_command!(MidiEditCommand: |state: MidiEditor| {
|
|||
SetTimeLock(bool),
|
||||
Show(Option<Arc<RwLock<MidiClip>>>),
|
||||
}
|
||||
impl MidiEditCommand {
|
||||
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_atom(key) => {
|
||||
return Ok(MidiEditCommand::from_atom(state, command, args))
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
} else {
|
||||
panic!("invalid config")
|
||||
}
|
||||
}
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
handle!(TuiIn: |self: MidiEditor, input|{
|
||||
Ok(if let Some(command) = MidiEditCommand::from_tui_event(self, input)? {
|
||||
Ok(if let Some(command) = self.keys.command::<_, MidiEditCommand, _>(self, input) {
|
||||
let _undo = command.execute(self)?;
|
||||
Some(true)
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue