Hi,
I'm currently building an application to find and highlight rhymes in song lyrics.
I'm converting the text into IPA and then syllables.
I'm using iced to create a gui, which for now only shows the text, the corresponding ipa syllables and highlights them the same color if they share the same syllable nucleus.
Now i wanted to implement highlighting all syllables that belong to a rhyme, but i got stuck. I need a way to link a display element of iced to the syllables struct. How do I do that?
#[derive(Debug)]
struct Rhyme {
color: Color,
members: Vec<Arc<RwLock<DisplaySyllable>>>,
}
#[derive(Debug)]
struct DisplayWord {
text: String,
syllables: Option<Vec<Arc<RwLock<DisplaySyllable>>>>,
}
#[derive(Debug)]
struct DisplaySyllable {
syllable: Syllable,
rhymes: Vec<Arc<RwLock<RhymeSyllable>>>,
}
#[derive(Debug)]
struct RhymeSyllable {
cur: Arc<RwLock<DisplaySyllable>>,
rhyme: Arc<RwLock<Rhyme>>,
prev: Option<Arc<RwLock<DisplaySyllable>>>,
prev_dist: Option<usize>,
next: Option<Arc<RwLock<DisplaySyllable>>>,
next_dist: Option<usize>,
}
struct App {
raw_text: String,
text: Vec<Vec<Arc<RwLock<DisplayWord>>>>,
rhymes: Vec<Arc<RwLock<Rhyme>>>,
}
Right now these are the structs I'm using, as i want to be able to access the next rhyme members from a specific rhyming syllables. It gets kinda complicated, as each syllable can be part of many rhymes, depending on the definition (pure rhyme, alliteration etc) Am I overcomplicating things?
I tried to use iced's MouseArea to send a Message with an Arc<RwLock> but, when i do that, my program segfaults. Also just trying to send an Arc<RwLock<>> cloned from the App seems to not compile, saying the reference doesnt live long enough. Should i not use Messges for that?
Heres the github repo: https://github.com/Paulemeister/rhymalize, the gui application is under src/bin/rhymalize-gui