wip: p.59, e=54

This commit is contained in:
🪞👃🪞 2024-11-19 23:05:17 +01:00
parent e95230a340
commit f4a4b08c8a
3 changed files with 38 additions and 56 deletions

View file

@ -147,8 +147,16 @@ where
key!(KeyCode::Up) => match state.selected() {
Select::Mix => return None,
Select::Track(t) => return None,
Select::Scene(s) => Select(Select::Scene(s - 1)),
Select::Clip(t, s) => Select(Select::Clip(t, s - 1)),
Select::Scene(s) => if s > 0 {
Select(Select::Scene(s - 1))
} else {
Select(Select::Mix)
},
Select::Clip(t, s) => if s > 0 {
Select(Select::Clip(t, s - 1))
} else {
Select(Select::Track(t))
},
},
key!(KeyCode::Down) => match state.selected() {
@ -160,9 +168,17 @@ where
key!(KeyCode::Left) => match state.selected() {
Select::Mix => return None,
Select::Track(t) => Select(Select::Track(t - 1)),
Select::Track(t) => if t > 0 {
Select(Select::Track(t - 1))
} else {
Select(Select::Mix)
},
Select::Scene(s) => return None,
Select::Clip(t, s) => Select(Select::Clip(t - 1, s)),
Select::Clip(t, s) => if t > 0 {
Select(Select::Clip(t - 1, s))
} else {
Select(Select::Scene(s))
},
},
key!(KeyCode::Right) => match state.selected() {
@ -256,31 +272,31 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
use PhrasePoolCommand as Phrase;
use PhraseRenameCommand as Rename;
use PhraseLengthCommand as Length;
let index = state.phrase();
let index = state.phrase_index();
let count = state.phrases().len();
match input.event() {
key!(KeyCode::Up) => Some(Self::Select(0)),
key!(KeyCode::Down) => Some(Self::Select(0)),
key!(KeyCode::Char(',')) => {
if index > 1 {
*state.phrase_index_mut() -= 1;
Some(Self::Phrase(Phrase::Swap(index - 1, index)))
//index -= 1;
} else {
None
}
},
key!(KeyCode::Char('.')) => {
if index < count.saturating_sub(1) {
*state.phrase_index_mut() += 1;
Some(Self::Phrase(Phrase::Swap(index + 1, index)))
//index += 1;
} else {
None
}
},
key!(KeyCode::Delete) => {
if index > 0 {
Some(Self::Delete(index))
//index = index.min(count.saturating_sub(1));
*state.phrase_index_mut() = index.min(count.saturating_sub(1));
Some(Self::Phrase(Phrase::Delete(index)))
} else {
None
}
@ -288,7 +304,7 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
key!(KeyCode::Char('a')) => Some(Self::Phrase(Phrase::Add(count))),
key!(KeyCode::Char('i')) => Some(Self::Phrase(Phrase::Add(index + 1))),
key!(KeyCode::Char('d')) => Some(Self::Phrase(Phrase::Duplicate(index))),
key!(KeyCode::Char('c')) => Some(Self::Phrase(Phrase::RandomColor(index))),
key!(KeyCode::Char('c')) => Some(Self::Phrase(Phrase::Color(index, ItemColor::random()))),
key!(KeyCode::Char('n')) => Some(Self::Rename(Rename::Begin)),
key!(KeyCode::Char('t')) => Some(Self::Length(Length::Begin)),
_ => match state.phrases_mode() {