mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
wip: midi import/export browser, pt.5
This commit is contained in:
parent
bd354bbc67
commit
4adb8d45fe
4 changed files with 35 additions and 18 deletions
|
|
@ -275,6 +275,11 @@ impl<T: PhrasesControl> Command<T> for FileBrowserCommand {
|
|||
index, FileBrowser::new(Some(cwd))?
|
||||
));
|
||||
},
|
||||
Select(index) => {
|
||||
*state.phrases_mode_mut() = Some(PhrasesMode::Import(
|
||||
index, browser
|
||||
))
|
||||
},
|
||||
_ => todo!(),
|
||||
_ => unreachable!()
|
||||
},
|
||||
|
|
@ -287,6 +292,11 @@ impl<T: PhrasesControl> Command<T> for FileBrowserCommand {
|
|||
index, FileBrowser::new(Some(cwd))?
|
||||
));
|
||||
},
|
||||
Select(index) => {
|
||||
*state.phrases_mode_mut() = Some(PhrasesMode::Import(
|
||||
index, browser
|
||||
))
|
||||
},
|
||||
_ => unreachable!()
|
||||
},
|
||||
_ => unreachable!(),
|
||||
|
|
|
|||
|
|
@ -188,11 +188,18 @@ impl Content for FileBrowser {
|
|||
type Engine = Tui;
|
||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
Stack::down(|add|{
|
||||
let mut i = 0;
|
||||
for (_, name) in self.dirs.iter() {
|
||||
add(&name.as_str())?;
|
||||
if i >= self.scroll {
|
||||
add(&TuiStyle::bold(name.as_str(), i == self.index))?;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
for (_, name) in self.files.iter() {
|
||||
add(&name.as_str())?;
|
||||
if i >= self.scroll {
|
||||
add(&TuiStyle::bold(name.as_str(), i == self.index))?;
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ where
|
|||
}
|
||||
|
||||
fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<SequencerCommand> {
|
||||
use SequencerCommand as Cmd;
|
||||
use SequencerCommand::*;
|
||||
if !state.entered() {
|
||||
return None
|
||||
}
|
||||
|
|
@ -98,18 +98,14 @@ fn to_sequencer_command (state: &SequencerTui, input: &TuiInput) -> Option<Seque
|
|||
todo!()
|
||||
},
|
||||
AppFocus::Content(focused) => match focused {
|
||||
SequencerFocus::Phrases => Phrases(PhrasesCommand::input_to_command(state, input)?),
|
||||
SequencerFocus::PhraseEditor => Editor(PhraseCommand::input_to_command(state, input)?),
|
||||
SequencerFocus::Transport(_) => {
|
||||
match TransportCommand::input_to_command(state, input)? {
|
||||
TransportCommand::Clock(_) => { todo!() },
|
||||
TransportCommand::Focus(command) => Cmd::Focus(command),
|
||||
TransportCommand::Focus(command) => Focus(command),
|
||||
}
|
||||
},
|
||||
SequencerFocus::Phrases => {
|
||||
Cmd::Phrases(PhrasesCommand::input_to_command(state, input)?)
|
||||
},
|
||||
SequencerFocus::PhraseEditor => {
|
||||
Cmd::Editor(PhraseCommand::input_to_command(state, input)?)
|
||||
},
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -317,12 +313,13 @@ fn to_phrases_command <T: PhrasesControl> (state: &T, input: &TuiInput) -> Optio
|
|||
impl<T: PhrasesControl> InputToCommand<Tui, T> for FileBrowserCommand {
|
||||
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
|
||||
use KeyCode::{Up, Down, Right, Left, Enter, Esc, Char, Backspace};
|
||||
use FileBrowserCommand::*;
|
||||
if let Some(PhrasesMode::Import(index, browser)) = state.phrases_mode() {
|
||||
Some(match from.event() {
|
||||
key!(Up) => Self::Select(0),
|
||||
key!(Down) => Self::Select(0),
|
||||
key!(Right) => Self::Chdir(browser.cwd.clone()),
|
||||
key!(Left) => Self::Chdir(browser.cwd.clone()),
|
||||
key!(Up) => Select(browser.index.overflowing_sub(1).0.min(browser.len())),
|
||||
key!(Down) => Select(browser.index.saturating_add(1) % browser.len()),
|
||||
key!(Right) => Chdir(browser.cwd.clone()),
|
||||
key!(Left) => Chdir(browser.cwd.clone()),
|
||||
key!(Enter) => { todo!() },
|
||||
key!(Char(c)) => { todo!() },
|
||||
key!(Backspace) => { todo!() },
|
||||
|
|
@ -331,10 +328,10 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for FileBrowserCommand {
|
|||
})
|
||||
} else if let Some(PhrasesMode::Export(index, browser)) = state.phrases_mode() {
|
||||
Some(match from.event() {
|
||||
key!(Up) => Self::Select(0),
|
||||
key!(Down) => Self::Select(0),
|
||||
key!(Right) => Self::Chdir(browser.cwd.clone()),
|
||||
key!(Left) => Self::Chdir(browser.cwd.clone()),
|
||||
key!(Up) => Select(browser.index.overflowing_sub(1).0.min(browser.len())),
|
||||
key!(Down) => Select(browser.index.saturating_add(1) % browser.len()),
|
||||
key!(Right) => Chdir(browser.cwd.clone()),
|
||||
key!(Left) => Chdir(browser.cwd.clone()),
|
||||
key!(Enter) => { todo!() },
|
||||
key!(Char(c)) => { todo!() },
|
||||
key!(Backspace) => { todo!() },
|
||||
|
|
|
|||
|
|
@ -206,6 +206,9 @@ impl FileBrowser {
|
|||
size: Measure::new(),
|
||||
})
|
||||
}
|
||||
pub fn len (&self) -> usize {
|
||||
self.dirs.len() + self.files.len()
|
||||
}
|
||||
}
|
||||
|
||||
/// Displays and edits phrase length.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue