From 8d8bba1ccc81796967422393a69def07e0fa47e6 Mon Sep 17 00:00:00 2001 From: rushmore75 Date: Sat, 29 Mar 2025 11:43:47 -0600 Subject: [PATCH] generally improved --- src/main.rs | 42 +++++++++++++++++++++++++++++------------- src/texts/bible.rs | 2 +- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/main.rs b/src/main.rs index 74cba31..de232f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,8 @@ #![feature(iter_map_windows)] use iced::{ - Element, Length, Task, clipboard, - widget::{ - self, button, column, combo_box, row, scrollable, - scrollable::{Direction, Scrollbar}, - text, text_input, - }, + clipboard, color, widget::{ + self, button, column, combo_box, row, scrollable, scrollable::{Direction, Scrollbar}, text, text_input + }, Element, Length, Task, Theme }; use std::{env, fs, path::PathBuf}; use texts::*; @@ -34,7 +31,9 @@ fn main() -> iced::Result { } // GUI - iced::run("Bible Search", State::update, State::view) + iced::application("Bible Study", State::update, State::view) + .theme(|_| Theme::Nord) + .run() } #[derive(Debug, Clone)] @@ -178,6 +177,7 @@ impl State { scrollable(row![ row((0..self.cols).map(|col_index| { column![ + // header combo_box( &self.files, "Select Bible", @@ -199,6 +199,7 @@ impl State { .on_press_with(move || Message::CopyText(col_index)), ], row![ + // Word search results scrollable( column( self.states[col_index] @@ -214,14 +215,28 @@ impl State { .into()) ) .padding([5, 5]) - ), - scrollable(text( - if let Some(body) = self.states[col_index].scripture_body.clone() { - parse(&body) + ) + .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 { - String::new() + column( + Vec::::new().iter().map(|_| text(String::new()).into()) + ) } - )) + ) + .spacing(5) ], ] .padding([10, 5]) @@ -316,3 +331,4 @@ fn parse(input: &str) -> String { modified } + diff --git a/src/texts/bible.rs b/src/texts/bible.rs index 19f9c38..b3313f5 100644 --- a/src/texts/bible.rs +++ b/src/texts/bible.rs @@ -78,7 +78,7 @@ pub fn search_for_word(word: &str, from_files: &Bible) -> Vec { for book in &test.books { for chapter in &book.chapters { for verse in &chapter.verses { - if verse.text.contains(word) { + if verse.text.to_lowercase().contains(&word.to_lowercase()) { found.push(format!("{} {}:{}", BOOKS_IN_ORDER[book.number-1], chapter.number, verse.number)); } }