mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 04:06:45 +01:00
add phrase names
This commit is contained in:
parent
4081c23aea
commit
0c5967a915
2 changed files with 8 additions and 3 deletions
|
|
@ -248,7 +248,7 @@ impl Phrase {
|
|||
}
|
||||
}
|
||||
impl Default for Phrase {
|
||||
fn default () -> Self { Self::new("", false, 0, None, Some(Color::Rgb(0, 0, 0))) }
|
||||
fn default () -> Self { Self::new("(empty)", false, 0, None, Some(Color::Rgb(0, 0, 0))) }
|
||||
}
|
||||
impl std::cmp::PartialEq for Phrase {
|
||||
fn eq (&self, other: &Self) -> bool {
|
||||
|
|
|
|||
|
|
@ -46,8 +46,11 @@ impl Content for PhrasePool<Tui> {
|
|||
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||
let content = col!(
|
||||
(i, phrase) in self.phrases.iter().enumerate() => Layers::new(|add|{
|
||||
let color = phrase.read().unwrap().color;
|
||||
add(&format!(" {i}").fixed_y(2).bg(if i == self.phrase {
|
||||
let Phrase { ref name, color, .. } = *phrase.read().unwrap();
|
||||
add(&col!(
|
||||
format!(" {i}"),
|
||||
format!(" {}", name.read().unwrap()),
|
||||
).fill_x().bg(if i == self.phrase {
|
||||
color //Color::Rgb(40, 50, 30)
|
||||
} else {
|
||||
color //Color::Rgb(28, 35, 25)
|
||||
|
|
@ -96,12 +99,14 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
|||
},
|
||||
key!(KeyCode::Char('a')) => { // append new
|
||||
let mut phrase = Phrase::default();
|
||||
phrase.name = Arc::new(RwLock::new("(no name)".to_string()));
|
||||
phrase.color = random_color();
|
||||
self.phrases.push(Arc::new(RwLock::new(phrase)));
|
||||
self.phrase = self.phrases.len() - 1;
|
||||
},
|
||||
key!(KeyCode::Char('i')) => { // insert new
|
||||
let mut phrase = Phrase::default();
|
||||
phrase.name = Arc::new(RwLock::new("(no name)".to_string()));
|
||||
phrase.color = random_color();
|
||||
self.phrases.insert(self.phrase, Arc::new(RwLock::new(phrase)));
|
||||
self.phrase += 1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue