mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-08 20:56:43 +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 {
|
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 {
|
impl std::cmp::PartialEq for Phrase {
|
||||||
fn eq (&self, other: &Self) -> bool {
|
fn eq (&self, other: &Self) -> bool {
|
||||||
|
|
|
||||||
|
|
@ -46,8 +46,11 @@ impl Content for PhrasePool<Tui> {
|
||||||
fn content (&self) -> impl Widget<Engine = Tui> {
|
fn content (&self) -> impl Widget<Engine = Tui> {
|
||||||
let content = col!(
|
let content = col!(
|
||||||
(i, phrase) in self.phrases.iter().enumerate() => Layers::new(|add|{
|
(i, phrase) in self.phrases.iter().enumerate() => Layers::new(|add|{
|
||||||
let color = phrase.read().unwrap().color;
|
let Phrase { ref name, color, .. } = *phrase.read().unwrap();
|
||||||
add(&format!(" {i}").fixed_y(2).bg(if i == self.phrase {
|
add(&col!(
|
||||||
|
format!(" {i}"),
|
||||||
|
format!(" {}", name.read().unwrap()),
|
||||||
|
).fill_x().bg(if i == self.phrase {
|
||||||
color //Color::Rgb(40, 50, 30)
|
color //Color::Rgb(40, 50, 30)
|
||||||
} else {
|
} else {
|
||||||
color //Color::Rgb(28, 35, 25)
|
color //Color::Rgb(28, 35, 25)
|
||||||
|
|
@ -96,12 +99,14 @@ impl Handle<Tui> for PhrasePool<Tui> {
|
||||||
},
|
},
|
||||||
key!(KeyCode::Char('a')) => { // append new
|
key!(KeyCode::Char('a')) => { // append new
|
||||||
let mut phrase = Phrase::default();
|
let mut phrase = Phrase::default();
|
||||||
|
phrase.name = Arc::new(RwLock::new("(no name)".to_string()));
|
||||||
phrase.color = random_color();
|
phrase.color = random_color();
|
||||||
self.phrases.push(Arc::new(RwLock::new(phrase)));
|
self.phrases.push(Arc::new(RwLock::new(phrase)));
|
||||||
self.phrase = self.phrases.len() - 1;
|
self.phrase = self.phrases.len() - 1;
|
||||||
},
|
},
|
||||||
key!(KeyCode::Char('i')) => { // insert new
|
key!(KeyCode::Char('i')) => { // insert new
|
||||||
let mut phrase = Phrase::default();
|
let mut phrase = Phrase::default();
|
||||||
|
phrase.name = Arc::new(RwLock::new("(no name)".to_string()));
|
||||||
phrase.color = random_color();
|
phrase.color = random_color();
|
||||||
self.phrases.insert(self.phrase, Arc::new(RwLock::new(phrase)));
|
self.phrases.insert(self.phrase, Arc::new(RwLock::new(phrase)));
|
||||||
self.phrase += 1;
|
self.phrase += 1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue