mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 12:16:42 +01:00
wip: rename phrase
This commit is contained in:
parent
db2a2efa63
commit
4081c23aea
2 changed files with 21 additions and 2 deletions
|
|
@ -30,7 +30,11 @@ pub struct PhrasePool<E: Engine> {
|
||||||
pub phrases: Vec<Arc<RwLock<Phrase>>>,
|
pub phrases: Vec<Arc<RwLock<Phrase>>>,
|
||||||
/// Whether this widget is focused
|
/// Whether this widget is focused
|
||||||
pub focused: bool,
|
pub focused: bool,
|
||||||
|
/// Mode switch
|
||||||
|
pub mode: Option<PhrasePoolMode>,
|
||||||
}
|
}
|
||||||
|
/// Modes for phrase pool
|
||||||
|
pub enum PhrasePoolMode { Rename(usize) }
|
||||||
/// A MIDI sequence.
|
/// A MIDI sequence.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Phrase {
|
pub struct Phrase {
|
||||||
|
|
@ -129,7 +133,8 @@ impl<E: Engine> PhrasePool<E> {
|
||||||
scroll: 0,
|
scroll: 0,
|
||||||
phrase: 0,
|
phrase: 0,
|
||||||
phrases: vec![Arc::new(RwLock::new(Phrase::default()))],
|
phrases: vec![Arc::new(RwLock::new(Phrase::default()))],
|
||||||
focused: false
|
focused: false,
|
||||||
|
mode: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn phrase (&self) -> &Arc<RwLock<Phrase>> {
|
pub fn phrase (&self) -> &Arc<RwLock<Phrase>> {
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,18 @@ impl Content for PhrasePool<Tui> {
|
||||||
} else {
|
} else {
|
||||||
color //Color::Rgb(28, 35, 25)
|
color //Color::Rgb(28, 35, 25)
|
||||||
}))?;
|
}))?;
|
||||||
if self.focused && i == self.phrase { add(&CORNERS)?; }
|
match self.mode {
|
||||||
|
None => {
|
||||||
|
if self.focused && i == self.phrase { add(&CORNERS)?; }
|
||||||
|
},
|
||||||
|
Some(PhrasePoolMode::Rename(phrase)) => {
|
||||||
|
if self.focused && i == phrase {
|
||||||
|
add(&CORNERS)?;
|
||||||
|
add(&"Rename")?;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
|
|
@ -104,6 +115,9 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
||||||
let mut phrase = self.phrases[self.phrase].write().unwrap();
|
let mut phrase = self.phrases[self.phrase].write().unwrap();
|
||||||
phrase.color = random_color();
|
phrase.color = random_color();
|
||||||
},
|
},
|
||||||
|
key!(KeyCode::Char('n')) => { // change name
|
||||||
|
self.mode = Some(PhrasePoolMode::Rename(self.phrase));
|
||||||
|
},
|
||||||
_ => return Ok(None),
|
_ => return Ok(None),
|
||||||
}
|
}
|
||||||
return Ok(Some(true))
|
return Ok(Some(true))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue