mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
86 lines
5.2 KiB
Rust
86 lines
5.2 KiB
Rust
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
//fn to_clips_command (state: &MidiPool, input: &Event) -> Option<PoolCommand> {
|
|
//use KeyCode::{Up, Down, Delete, Char};
|
|
//use PoolCommand as Cmd;
|
|
//let index = state.clip_index();
|
|
//let count = state.clips().len();
|
|
//Some(match input {
|
|
//kpat!(Char('n')) => Cmd::Rename(ClipRenameCommand::Begin),
|
|
//kpat!(Char('t')) => Cmd::Length(ClipLengthCommand::Begin),
|
|
//kpat!(Char('m')) => Cmd::Import(FileBrowserCommand::Begin),
|
|
//kpat!(Char('x')) => Cmd::Export(FileBrowserCommand::Begin),
|
|
//kpat!(Char('c')) => Cmd::Clip(PoolClipCommand::SetColor(index, ItemColor::random())),
|
|
//kpat!(Char('[')) | kpat!(Up) => Cmd::Select(
|
|
//index.overflowing_sub(1).0.min(state.clips().len() - 1)
|
|
//),
|
|
//kpat!(Char(']')) | kpat!(Down) => Cmd::Select(
|
|
//index.saturating_add(1) % state.clips().len()
|
|
//),
|
|
//kpat!(Char('<')) => if index > 1 {
|
|
//state.set_clip_index(state.clip_index().saturating_sub(1));
|
|
//Cmd::Clip(PoolClipCommand::Swap(index - 1, index))
|
|
//} else {
|
|
//return None
|
|
//},
|
|
//kpat!(Char('>')) => if index < count.saturating_sub(1) {
|
|
//state.set_clip_index(state.clip_index() + 1);
|
|
//Cmd::Clip(PoolClipCommand::Swap(index + 1, index))
|
|
//} else {
|
|
//return None
|
|
//},
|
|
//kpat!(Delete) => if index > 0 {
|
|
//state.set_clip_index(index.min(count.saturating_sub(1)));
|
|
//Cmd::Clip(PoolClipCommand::Delete(index))
|
|
//} else {
|
|
//return None
|
|
//},
|
|
//kpat!(Char('a')) | kpat!(Shift-Char('A')) => Cmd::Clip(PoolClipCommand::Add(count, MidiClip::new(
|
|
//"Clip", true, 4 * PPQ, None, Some(ItemPalette::random())
|
|
//))),
|
|
//kpat!(Char('i')) => Cmd::Clip(PoolClipCommand::Add(index + 1, MidiClip::new(
|
|
//"Clip", true, 4 * PPQ, None, Some(ItemPalette::random())
|
|
//))),
|
|
//kpat!(Char('d')) | kpat!(Shift-Char('D')) => {
|
|
//let mut clip = state.clips()[index].read().unwrap().duplicate();
|
|
//clip.color = ItemPalette::random_near(clip.color, 0.25);
|
|
//Cmd::Clip(PoolClipCommand::Add(index + 1, clip))
|
|
//},
|
|
//_ => return None
|
|
//})
|
|
//}
|
|
//keymap!(KEYS_MIDI_EDITOR = |s: MidiEditor, _input: Event| MidiEditCommand {
|
|
//key(Up) => SetNoteCursor(s.note_pos() + 1),
|
|
//key(Char('w')) => SetNoteCursor(s.note_pos() + 1),
|
|
//key(Down) => SetNoteCursor(s.note_pos().saturating_sub(1)),
|
|
//key(Char('s')) => SetNoteCursor(s.note_pos().saturating_sub(1)),
|
|
//key(Left) => SetTimeCursor(s.time_pos().saturating_sub(s.note_len())),
|
|
//key(Char('a')) => SetTimeCursor(s.time_pos().saturating_sub(s.note_len())),
|
|
//key(Right) => SetTimeCursor((s.time_pos() + s.note_len()) % s.clip_length()),
|
|
//ctrl(alt(key(Up))) => SetNoteScroll(s.note_pos() + 3),
|
|
//ctrl(alt(key(Down))) => SetNoteScroll(s.note_pos().saturating_sub(3)),
|
|
//ctrl(alt(key(Left))) => SetTimeScroll(s.time_pos().saturating_sub(s.time_zoom().get())),
|
|
//ctrl(alt(key(Right))) => SetTimeScroll((s.time_pos() + s.time_zoom().get()) % s.clip_length()),
|
|
//ctrl(key(Up)) => SetNoteScroll(s.note_lo().get() + 1),
|
|
//ctrl(key(Down)) => SetNoteScroll(s.note_lo().get().saturating_sub(1)),
|
|
//ctrl(key(Left)) => SetTimeScroll(s.time_start().get().saturating_sub(s.note_len())),
|
|
//ctrl(key(Right)) => SetTimeScroll(s.time_start().get() + s.note_len()),
|
|
//alt(key(Up)) => SetNoteCursor(s.note_pos() + 3),
|
|
//alt(key(Down)) => SetNoteCursor(s.note_pos().saturating_sub(3)),
|
|
//alt(key(Left)) => SetTimeCursor(s.time_pos().saturating_sub(s.time_zoom().get())),
|
|
//alt(key(Right)) => SetTimeCursor((s.time_pos() + s.time_zoom().get()) % s.clip_length()),
|
|
//key(Char('d')) => SetTimeCursor((s.time_pos() + s.note_len()) % s.clip_length()),
|
|
//key(Char('z')) => SetTimeLock(!s.time_lock().get()),
|
|
//key(Char('-')) => SetTimeZoom(if s.time_lock().get() { s.time_zoom().get() } else { NoteDuration::next(s.time_zoom().get()) }),
|
|
//key(Char('_')) => SetTimeZoom(if s.time_lock().get() { s.time_zoom().get() } else { NoteDuration::next(s.time_zoom().get()) }),
|
|
//key(Char('=')) => SetTimeZoom(if s.time_lock().get() { s.time_zoom().get() } else { NoteDuration::prev(s.time_zoom().get()) }),
|
|
//key(Char('+')) => SetTimeZoom(if s.time_lock().get() { s.time_zoom().get() } else { NoteDuration::prev(s.time_zoom().get()) }),
|
|
//key(Enter) => PutNote,
|
|
//ctrl(key(Enter)) => AppendNote,
|
|
//key(Char(',')) => SetNoteLength(NoteDuration::prev(s.note_len())),
|
|
//key(Char('.')) => SetNoteLength(NoteDuration::next(s.note_len())),
|
|
//key(Char('<')) => SetNoteLength(NoteDuration::prev(s.note_len())),
|
|
//key(Char('>')) => SetNoteLength(NoteDuration::next(s.note_len())),
|
|
////// TODO: kpat!(Char('/')) => // toggle 3plet
|
|
////// TODO: kpat!(Char('?')) => // toggle dotted
|
|
//});
|
|
|