reenable more phrase commands

This commit is contained in:
🪞👃🪞 2024-11-24 00:47:07 +01:00
parent 964a4fec8f
commit 35944cf684
3 changed files with 22 additions and 20 deletions

View file

@ -117,11 +117,6 @@ pub trait PhrasesControl: HasPhrases {
PhrasesMode::Length(self.phrase_index(), length, PhraseLengthFocus::Bar)
)
}
fn new_phrase (name: Option<&str>, color: Option<ItemColorTriplet>) -> Arc<RwLock<Phrase>> {
Arc::new(RwLock::new(Phrase::new(
String::from(name.unwrap_or("(new)")), true, 4 * PPQ, None, color
)))
}
fn index_of (&self, phrase: &Phrase) -> Option<usize> {
for i in 0..self.phrases().len() {
if *self.phrases()[i].read().unwrap() == *phrase { return Some(i) }

View file

@ -272,9 +272,22 @@ impl<T: PhrasesControl> InputToCommand<Tui, T> for PhrasesCommand {
} else {
return None
},
key!(Char('a')) => Self::Phrase(Pool::Add(count, Phrase::default())),
key!(Char('i')) => Self::Phrase(Pool::Add(index + 1, Phrase::default())),
key!(Char('d')) => Self::Phrase(Pool::Duplicate(index)),
key!(Char('a')) => Self::Phrase(Pool::Add(
count,
Phrase::new(
String::from("(new)"), true, 4 * PPQ, None, Some(ItemColorTriplet::random())
)
)),
key!(Char('i')) => Self::Phrase(Pool::Add(
index + 1,
Phrase::new(
String::from("(new)"), true, 4 * PPQ, None, Some(ItemColorTriplet::random())
)
)),
key!(Char('d')) => Self::Phrase(Pool::Add(
index + 1,
state.phrases()[index].read().unwrap().duplicate()
)),
key!(Char('c')) => Self::Phrase(Pool::Color(index, ItemColor::random())),
key!(Char('n')) => Self::Rename(Rename::Begin),
key!(Char('t')) => Self::Length(Length::Begin),