mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 11:46:41 +01:00
reorder phrases in phrase list
This commit is contained in:
parent
ea88622081
commit
7a6bdf2764
2 changed files with 14 additions and 0 deletions
|
|
@ -191,6 +191,18 @@ impl<E: Engine> PhrasePool<E> {
|
|||
let phrase = self.phrases[self.phrase].read().unwrap();
|
||||
self.mode = Some(PhrasePoolMode::Rename(self.phrase, phrase.name.clone()));
|
||||
}
|
||||
pub fn move_up (&mut self) {
|
||||
if self.phrase > 1 {
|
||||
self.phrases.swap(self.phrase - 1, self.phrase);
|
||||
self.phrase -= 1;
|
||||
}
|
||||
}
|
||||
pub fn move_down (&mut self) {
|
||||
if self.phrase < self.phrases.len().saturating_sub(1) {
|
||||
self.phrases.swap(self.phrase + 1, self.phrase);
|
||||
self.phrase += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<E: Engine> PhraseEditor<E> {
|
||||
pub fn new () -> Self {
|
||||
|
|
|
|||
|
|
@ -51,6 +51,8 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
|||
key!(KeyCode::Char('d')) => { self.insert_dup() },
|
||||
key!(KeyCode::Char('c')) => { self.randomize_color() },
|
||||
key!(KeyCode::Char('n')) => { self.begin_rename() },
|
||||
key!(KeyCode::Char(',')) => { self.move_up() },
|
||||
key!(KeyCode::Char('.')) => { self.move_down() },
|
||||
_ => return Ok(None),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue