generally improved
This commit is contained in:
parent
8a10b62755
commit
8d8bba1ccc
42
src/main.rs
42
src/main.rs
@ -1,11 +1,8 @@
|
|||||||
#![feature(iter_map_windows)]
|
#![feature(iter_map_windows)]
|
||||||
use iced::{
|
use iced::{
|
||||||
Element, Length, Task, clipboard,
|
clipboard, color, widget::{
|
||||||
widget::{
|
self, button, column, combo_box, row, scrollable, scrollable::{Direction, Scrollbar}, text, text_input
|
||||||
self, button, column, combo_box, row, scrollable,
|
}, Element, Length, Task, Theme
|
||||||
scrollable::{Direction, Scrollbar},
|
|
||||||
text, text_input,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
use std::{env, fs, path::PathBuf};
|
use std::{env, fs, path::PathBuf};
|
||||||
use texts::*;
|
use texts::*;
|
||||||
@ -34,7 +31,9 @@ fn main() -> iced::Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// GUI
|
// GUI
|
||||||
iced::run("Bible Search", State::update, State::view)
|
iced::application("Bible Study", State::update, State::view)
|
||||||
|
.theme(|_| Theme::Nord)
|
||||||
|
.run()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -178,6 +177,7 @@ impl State {
|
|||||||
scrollable(row![
|
scrollable(row![
|
||||||
row((0..self.cols).map(|col_index| {
|
row((0..self.cols).map(|col_index| {
|
||||||
column![
|
column![
|
||||||
|
// header
|
||||||
combo_box(
|
combo_box(
|
||||||
&self.files,
|
&self.files,
|
||||||
"Select Bible",
|
"Select Bible",
|
||||||
@ -199,6 +199,7 @@ impl State {
|
|||||||
.on_press_with(move || Message::CopyText(col_index)),
|
.on_press_with(move || Message::CopyText(col_index)),
|
||||||
],
|
],
|
||||||
row![
|
row![
|
||||||
|
// Word search results
|
||||||
scrollable(
|
scrollable(
|
||||||
column(
|
column(
|
||||||
self.states[col_index]
|
self.states[col_index]
|
||||||
@ -214,14 +215,28 @@ impl State {
|
|||||||
.into())
|
.into())
|
||||||
)
|
)
|
||||||
.padding([5, 5])
|
.padding([5, 5])
|
||||||
),
|
)
|
||||||
scrollable(text(
|
.spacing(5),
|
||||||
if let Some(body) = self.states[col_index].scripture_body.clone() {
|
// Body
|
||||||
parse(&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 {
|
} else {
|
||||||
String::new()
|
text(msg.to_owned()).color(color![0xAAAAAA]).into()
|
||||||
}
|
}
|
||||||
))
|
}))
|
||||||
|
} else {
|
||||||
|
column(
|
||||||
|
Vec::<String>::new().iter().map(|_| text(String::new()).into())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.spacing(5)
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
.padding([10, 5])
|
.padding([10, 5])
|
||||||
@ -316,3 +331,4 @@ fn parse(input: &str) -> String {
|
|||||||
|
|
||||||
modified
|
modified
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ pub fn search_for_word(word: &str, from_files: &Bible) -> Vec<String> {
|
|||||||
for book in &test.books {
|
for book in &test.books {
|
||||||
for chapter in &book.chapters {
|
for chapter in &book.chapters {
|
||||||
for verse in &chapter.verses {
|
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));
|
found.push(format!("{} {}:{}", BOOKS_IN_ORDER[book.number-1], chapter.number, verse.number));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user