mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
delete phrase from list
This commit is contained in:
parent
c81fd97eb2
commit
708531571a
2 changed files with 7 additions and 0 deletions
|
|
@ -181,6 +181,12 @@ impl<E: Engine> PhrasePool<E> {
|
||||||
String::from(name.unwrap_or("(new)")), true, 4 * PPQ, None, color
|
String::from(name.unwrap_or("(new)")), true, 4 * PPQ, None, color
|
||||||
)))
|
)))
|
||||||
}
|
}
|
||||||
|
pub fn delete_selected (&mut self) {
|
||||||
|
if self.phrase > 0 {
|
||||||
|
self.phrases.remove(self.phrase);
|
||||||
|
self.phrase = self.phrase.min(self.phrases.len().saturating_sub(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
pub fn append_new (&mut self, name: Option<&str>, color: Option<Color>) {
|
pub fn append_new (&mut self, name: Option<&str>, color: Option<Color>) {
|
||||||
self.phrases.push(Self::new_phrase(name, color));
|
self.phrases.push(Self::new_phrase(name, color));
|
||||||
self.phrase = self.phrases.len() - 1;
|
self.phrase = self.phrases.len() - 1;
|
||||||
|
|
|
||||||
|
|
@ -68,6 +68,7 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
||||||
None => match from.event() {
|
None => match from.event() {
|
||||||
key!(KeyCode::Up) => { self.select_prev() },
|
key!(KeyCode::Up) => { self.select_prev() },
|
||||||
key!(KeyCode::Down) => { self.select_next() },
|
key!(KeyCode::Down) => { self.select_next() },
|
||||||
|
key!(KeyCode::Delete) => { self.delete_selected() },
|
||||||
key!(KeyCode::Char('a')) => { self.append_new(None, None) },
|
key!(KeyCode::Char('a')) => { self.append_new(None, None) },
|
||||||
key!(KeyCode::Char('i')) => { self.insert_new(None, None) },
|
key!(KeyCode::Char('i')) => { self.insert_new(None, None) },
|
||||||
key!(KeyCode::Char('d')) => { self.insert_dup() },
|
key!(KeyCode::Char('d')) => { self.insert_dup() },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue