mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-09 05:06:43 +01:00
remove old input macros
This commit is contained in:
parent
6fd87ce4ed
commit
ca1fb3c414
11 changed files with 218 additions and 247 deletions
|
|
@ -206,17 +206,13 @@ content!(TuiOut: |self: ClipLength| {
|
|||
}
|
||||
});
|
||||
impl PoolCommand {
|
||||
const KEYS_POOL: &str = include_str!("keys_pool.edn");
|
||||
const KEYS_FILE: &str = include_str!("keys_pool_file.edn");
|
||||
const KEYS_LENGTH: &str = include_str!("keys_clip_length.edn");
|
||||
const KEYS_RENAME: &str = include_str!("keys_clip_rename.edn");
|
||||
pub fn from_tui_event (state: &MidiPool, input: &impl EdnInput) -> Usually<Option<Self>> {
|
||||
use EdnItem::*;
|
||||
let edns: Vec<EdnItem<&str>> = EdnItem::read_all(match state.mode() {
|
||||
Some(PoolMode::Rename(..)) => Self::KEYS_RENAME,
|
||||
Some(PoolMode::Length(..)) => Self::KEYS_LENGTH,
|
||||
Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => Self::KEYS_FILE,
|
||||
_ => Self::KEYS_POOL
|
||||
Some(PoolMode::Rename(..)) => KEYS_RENAME,
|
||||
Some(PoolMode::Length(..)) => KEYS_LENGTH,
|
||||
Some(PoolMode::Import(..)) | Some(PoolMode::Export(..)) => KEYS_FILE,
|
||||
_ => KEYS_POOL
|
||||
})?;
|
||||
for item in edns {
|
||||
match item {
|
||||
|
|
@ -519,82 +515,6 @@ command!(|self: FileBrowserCommand, state: MidiPool|{
|
|||
None
|
||||
});
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
input_to_command!(FileBrowserCommand: |state: MidiPool, input: Event|{
|
||||
use FileBrowserCommand::*;
|
||||
use KeyCode::{Up, Down, Left, Right, Enter, Esc, Backspace, Char};
|
||||
if let Some(PoolMode::Import(_index, browser)) = &state.mode {
|
||||
match input {
|
||||
kpat!(Up) => Select(browser.index.overflowing_sub(1).0.min(browser.len().saturating_sub(1))),
|
||||
kpat!(Down) => Select(browser.index.saturating_add(1)% browser.len()),
|
||||
kpat!(Right) => Chdir(browser.cwd.clone()),
|
||||
kpat!(Left) => Chdir(browser.cwd.clone()),
|
||||
|
||||
kpat!(Enter) => Confirm,
|
||||
kpat!(Char(_)) => { todo!() },
|
||||
kpat!(Backspace) => { todo!() },
|
||||
kpat!(Esc) => Cancel,
|
||||
_ => return None
|
||||
}
|
||||
} else if let Some(PoolMode::Export(_index, browser)) = &state.mode {
|
||||
match input {
|
||||
kpat!(Up) => Select(browser.index.overflowing_sub(1).0.min(browser.len())),
|
||||
kpat!(Down) => Select(browser.index.saturating_add(1) % browser.len()),
|
||||
kpat!(Right) => Chdir(browser.cwd.clone()),
|
||||
kpat!(Left) => Chdir(browser.cwd.clone()),
|
||||
|
||||
kpat!(Enter) => Confirm,
|
||||
kpat!(Char(_)) => { todo!() },
|
||||
kpat!(Backspace) => { todo!() },
|
||||
kpat!(Esc) => Cancel,
|
||||
_ => return None
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
});
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
input_to_command!(ClipLengthCommand: |state: MidiPool, input: Event|{
|
||||
if let Some(PoolMode::Length(_, length, _)) = state.mode() {
|
||||
match input {
|
||||
kpat!(Up) => Self::Inc,
|
||||
kpat!(Down) => Self::Dec,
|
||||
kpat!(Right) => Self::Next,
|
||||
kpat!(Left) => Self::Prev,
|
||||
kpat!(Enter) => Self::Set(*length),
|
||||
kpat!(Esc) => Self::Cancel,
|
||||
_ => return None
|
||||
}
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
});
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
impl InputToCommand<Event, MidiPool> for ClipRenameCommand {
|
||||
fn input_to_command (state: &MidiPool, input: &Event) -> Option<Self> {
|
||||
use KeyCode::{Char, Backspace, Enter, Esc};
|
||||
if let Some(PoolMode::Rename(_, ref old_name)) = state.mode() {
|
||||
Some(match input {
|
||||
kpat!(Char(c)) => {
|
||||
let mut new_name = old_name.clone().to_string();
|
||||
new_name.push(*c);
|
||||
Self::Set(new_name.into())
|
||||
},
|
||||
kpat!(Backspace) => {
|
||||
let mut new_name = old_name.clone().to_string();
|
||||
new_name.pop();
|
||||
Self::Set(new_name.into())
|
||||
},
|
||||
kpat!(Enter) => Self::Confirm,
|
||||
kpat!(Esc) => Self::Cancel,
|
||||
_ => return None
|
||||
})
|
||||
} else {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//fn to_clips_command (state: &MidiPool, input: &Event) -> Option<PoolCommand> {
|
||||
//use KeyCode::{Up, Down, Delete, Char};
|
||||
//use PoolCommand as Cmd;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue