diff --git a/src/main.rs b/src/main.rs index f465a6c..daad6eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,10 +27,18 @@ fn main() -> iced::Result { } } if let Some(second_query) = arg.get(2) { - // if let Some(f) = bible::get( query, second_query, vec![format!("{BIBLE_DIRECTORY}/EnglishNASBBible.xml").into()], - // ) { - // println!("{}", f); - // } + if let Ok(contents) = fs::read_to_string(&format!("{BIBLE_DIRECTORY}/EnglishNASBBible.xml")) { + if let Ok(bible) = quick_xml::de::from_str::(&contents) { + if let Some(f) = bible::get( + query, + second_query, + vec![&bible], + ) { + println!("{}", f); + } + } + } + return Ok(()); } } @@ -208,93 +216,93 @@ impl State { } fn view(&self) -> Element { - scrollable(row![ - row((0..self.cols).map(|col_index| { - column![ - // header - button("Delete Column") - .on_press_with(move || Message::DeleteColumn(col_index)) - .width(Length::Fill) - .style(button::danger) - , - combo_box( - &self.files, - "Select Bible", - self.states[col_index].selected_file.as_ref(), - move |s| Message::BibleSelected(col_index, s) - ), - text_input( - "Search query, ie: Gen 1:1", - &self.states[col_index].bible_search - ) - .on_input(move |s| Message::BibleSearchInput(col_index, s)) - .on_submit(Message::BibleSearchSubmit(col_index)), - widget::text_input("Word Search", &self.states[col_index].word_search) - .on_input(move |s| Message::WordSearchInput(col_index, s)) - .on_submit(Message::SubmitWordSearch(col_index)), - row![ - button("Clear All") - .on_press_with(move || Message::Clear(col_index)) - .style(button::secondary) - , - button("Copy Scripture") - .on_press_with(move || Message::CopyText(col_index)) - .style(button::primary) - , - ] - .spacing(5), - row![ - // Word search results - scrollable( - column( - self.states[col_index] - .word_search_results - .clone() - .unwrap_or(Vec::new()) - .into_iter() - .map(|i| button(text(i.clone())) - .on_press_with(move || Message::QuickSearch( - col_index, - i.to_owned() - )) - .into()) - ) - .padding([5, 5]) + scrollable( + row![ + row((0..self.cols).map(|col_index| { + column![ + // header + button("Delete Column") + .on_press_with(move || Message::DeleteColumn(col_index)) + .width(Length::Fill) + .style(button::danger), + combo_box( + &self.files, + "Select Bible", + self.states[col_index].selected_file.as_ref(), + move |s| Message::BibleSelected(col_index, s) + ), + text_input( + "Search query, ie: Gen 1:1", + &self.states[col_index].bible_search ) + .on_input(move |s| Message::BibleSearchInput(col_index, s)) + .on_submit(Message::BibleSearchSubmit(col_index)), + widget::text_input("Word Search", &self.states[col_index].word_search) + .on_input(move |s| Message::WordSearchInput(col_index, s)) + .on_submit(Message::SubmitWordSearch(col_index)), + row![ + button("Clear All") + .on_press_with(move || Message::Clear(col_index)) + .style(button::secondary), + button("Copy Scripture") + .on_press_with(move || Message::CopyText(col_index)) + .style(button::primary), + ] .spacing(5), - // Body - scrollable(if let Some(body) = &self.states[col_index].scripture_body { - column(body.split("\n").enumerate().map(|(i, msg)| { - let msg = parse(msg); - if i & 1 == 0 { - text(msg.to_owned()).color(color![0xFFFFFF]).into() - } else { - text(msg.to_owned()).color(color![0xAAAAAA]).into() - } - })) - } else { - column( - Vec::::new() - .iter() - .map(|_| text(String::new()).into()), + row![ + // Word search results + scrollable( + column( + self.states[col_index] + .word_search_results + .clone() + .unwrap_or(Vec::new()) + .into_iter() + .map(|i| button(text(i.clone())) + .on_press_with(move || Message::QuickSearch( + col_index, + i.to_owned() + )) + .into()) + ) + .padding([5, 5]) ) - }) - .spacing(5) - ], - ] - .spacing(5) - .width(800.) - .into() - })), - button(text("+").center()) - .height(Length::Fixed(200.)) - .style(button::primary) - .on_press(Message::AddColRight) - ] - // 5 pixles css-like padding - .padding([5,5]) - // space elements inside this 5 pixels apart - .spacing(5) + .spacing(5), + // Body + scrollable( + if let Some(body) = &self.states[col_index].scripture_body { + column(body.split("\n").enumerate().map(|(i, msg)| { + let msg = parse(msg); + if i & 1 == 0 { + text(msg.to_owned()).color(color![0xFFFFFF]).into() + } else { + text(msg.to_owned()).color(color![0xAAAAAA]).into() + } + })) + } else { + column( + Vec::::new() + .iter() + .map(|_| text(String::new()).into()), + ) + } + ) + .spacing(5) + ], + ] + .spacing(5) + .width(800.) + .into() + })), + button(text("+").center()) + .height(Length::Fixed(200.)) + .style(button::primary) + .on_press(Message::AddColRight) + ] + // 5 pixles css-like padding + .padding([5, 5]) + // space elements inside this 5 pixels apart + .spacing(5), ) .direction(Direction::Horizontal(Scrollbar::new())) .into()