mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: midi import/export browser, pt.2
This commit is contained in:
parent
6d8dbc6780
commit
fab6113478
3 changed files with 42 additions and 5 deletions
|
|
@ -149,7 +149,7 @@ impl<T: PhrasesControl> Command<T> for PhrasesCommand {
|
||||||
Import(command) => match command {
|
Import(command) => match command {
|
||||||
FileBrowserCommand::Begin => {
|
FileBrowserCommand::Begin => {
|
||||||
*state.phrases_mode_mut() = Some(
|
*state.phrases_mode_mut() = Some(
|
||||||
PhrasesMode::Import(state.phrase_index(), FileBrowser::new())
|
PhrasesMode::Import(state.phrase_index(), FileBrowser::new(None)?)
|
||||||
);
|
);
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
|
|
@ -158,7 +158,7 @@ impl<T: PhrasesControl> Command<T> for PhrasesCommand {
|
||||||
Export(command) => match command {
|
Export(command) => match command {
|
||||||
FileBrowserCommand::Begin => {
|
FileBrowserCommand::Begin => {
|
||||||
*state.phrases_mode_mut() = Some(
|
*state.phrases_mode_mut() = Some(
|
||||||
PhrasesMode::Export(state.phrase_index(), FileBrowser::new())
|
PhrasesMode::Export(state.phrase_index(), FileBrowser::new(None)?)
|
||||||
);
|
);
|
||||||
None
|
None
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -316,7 +316,34 @@ fn to_phrases_command <T: PhrasesControl> (state: &T, input: &TuiInput) -> Optio
|
||||||
|
|
||||||
impl<T: PhrasesControl> InputToCommand<Tui, T> for FileBrowserCommand {
|
impl<T: PhrasesControl> InputToCommand<Tui, T> for FileBrowserCommand {
|
||||||
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
|
fn input_to_command (state: &T, from: &TuiInput) -> Option<Self> {
|
||||||
todo!()
|
use KeyCode::{Up, Down, Right, Left, Enter, Esc, Char, Backspace};
|
||||||
|
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!(Enter) => { todo!() },
|
||||||
|
key!(Char(c)) => { todo!() },
|
||||||
|
key!(Backspace) => { todo!() },
|
||||||
|
key!(Esc) => Self::Cancel,
|
||||||
|
_ => return None
|
||||||
|
})
|
||||||
|
} 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!(Enter) => { todo!() },
|
||||||
|
key!(Char(c)) => { todo!() },
|
||||||
|
key!(Backspace) => { todo!() },
|
||||||
|
key!(Esc) => Self::Cancel,
|
||||||
|
_ => return None
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -174,14 +174,24 @@ pub struct FileBrowser {
|
||||||
pub cwd: PathBuf,
|
pub cwd: PathBuf,
|
||||||
pub dirs: Vec<PathBuf>,
|
pub dirs: Vec<PathBuf>,
|
||||||
pub files: Vec<PathBuf>,
|
pub files: Vec<PathBuf>,
|
||||||
|
pub filter: String,
|
||||||
pub index: usize,
|
pub index: usize,
|
||||||
pub scroll: usize,
|
pub scroll: usize,
|
||||||
pub size: Measure<Tui>
|
pub size: Measure<Tui>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FileBrowser {
|
impl FileBrowser {
|
||||||
pub fn new () -> Self {
|
pub fn new (cwd: Option<PathBuf>) -> Usually<Self> {
|
||||||
todo!()
|
let cwd = if let Some(cwd) = cwd { cwd } else { std::env::current_dir()? };
|
||||||
|
Ok(Self {
|
||||||
|
cwd,
|
||||||
|
dirs: vec![/*todo*/],
|
||||||
|
files: vec![/*todo*/],
|
||||||
|
filter: "".to_string(),
|
||||||
|
index: 0,
|
||||||
|
scroll: 0,
|
||||||
|
size: Measure::new(),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue