diff --git a/.gitmodules b/.gitmodules index d852986..d1ae9ca 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/openscriptures/HebrewLexicon.git [submodule "Holy-Bible-XML-Format"] path = Holy-Bible-XML-Format - url = https://github.com/Beblia/Holy-Bible-XML-Format.git + url = https://github.com/Rushmore75/Holy-Bible-XML-Format.git diff --git a/Holy-Bible-XML-Format b/Holy-Bible-XML-Format index 69ac8b9..7413606 160000 --- a/Holy-Bible-XML-Format +++ b/Holy-Bible-XML-Format @@ -1 +1 @@ -Subproject commit 69ac8b94c9781f25483905ee08192ee4bf982317 +Subproject commit 7413606dd54f4fb2500f0a6174d0e8b832850392 diff --git a/README.md b/README.md index b3d1b46..932b0eb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# cli bible +# Bible ## Important Links @@ -12,3 +12,13 @@ [AndBible's formats](https://github.com/AndBible/and-bible/wiki/Supported-3rd-party-module-formats) +## TODOs + +- [ ]: When 1 scripture is open; put a button to view full chapter in new col +- [ ]: Button to add new col, same translation +- [ ]: Save all cols to file button +- [ ]: Only have 1 chapter/translation header for verse range copy +- [ ]: Pane widget could work for cols +- [ ]: Notes block at bottom of each col +- [ ]: Program doesn't wake back up from sleep very well + diff --git a/src/main.rs b/src/main.rs index 802a7b5..1d3ff4e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,20 +46,16 @@ fn main() -> iced::Result { } } - // THEMES - // Dark - KanagawaDragon - // Default - Nord - // Light - TokyoNightLight - // GUI iced::application("Bible Study", State::update, State::view) .subscription(State::subscription) - .theme(|_| Theme::Nord) + .theme(State::theme) .run() } #[derive(Debug, Clone)] enum Message { + CycleTheme, BibleSearchInput(usize, String), BibleSelected(usize, String), BibleSearchSubmit(usize), @@ -74,6 +70,27 @@ enum Message { RecievedEvent(Event), } +impl Message { + fn get_col_idx(&self) -> Option { + match self { + Message::SetErrorMessage(i, _) | + Message::BibleSearchInput(i, _) | + Message::BibleSelected(i, _) | + Message::BibleSearchSubmit(i) | + Message::CopyText(i) | + Message::Clear(i) | + Message::WordSearchInput(i, _) | + Message::SubmitWordSearch(i) | + Message::QuickSearch(i, _, _) | + Message::DeleteColumn(i) + => { + Some(*i) + }, + _ => None + } + } +} + struct ColState { selected_file: Option, bible_selected: Option, @@ -109,6 +126,10 @@ struct State { states: Vec, cols: usize, tab_index: Option, + + theme_idx: usize, + themes: [Theme; 3], + } impl Default for State { @@ -140,19 +161,45 @@ impl Default for State { states: vec![ColState::default()], cols: 1, tab_index: None, + // THEMES + // Dark - KanagawaDragon + // Default - Nord + // Light - TokyoNightLight + theme_idx: 0, + themes: [ + Theme::KanagawaDragon, + Theme::Nord, + Theme::TokyoNightLight + ] } } } impl State { + fn theme(&self) -> Theme { + self.themes[self.theme_idx].clone() + } fn subscription(&self) -> Subscription { event::listen().map(Message::RecievedEvent) } fn update(&mut self, msg: Message) -> Task { + // clear error messages + if let Some(idx) = msg.get_col_idx() { + self.states[idx].error = None + } // match normal messages match msg { + Message::CycleTheme => { + let len = self.themes.len(); + let i = &mut self.theme_idx; + if *i == len-1 { + *i = 0; + } else { + *i += 1; + } + }, Message::RecievedEvent(event) => { if let Event::Keyboard(kbd) = event { if let iced::keyboard::Event::KeyReleased {key, modifiers, ..} = kbd { @@ -163,7 +210,6 @@ impl State { // 2 because two buttons on each col let new_idx = new_idx.clamp(0, (self.cols*2) as i32 -1); - self.tab_index = Some(new_idx); let id = format!("tabId-{}", new_idx); @@ -201,7 +247,6 @@ impl State { // the Bible is held in memory in it's own variable. self.states[i].selected_file = Some(format!("{bible}")); self.states[i].bible_selected = Some(bible); - self.states[i].error = None; } Err(err) => { @@ -236,7 +281,6 @@ impl State { { self.states[i].scripture_body = match bible::get(book, chap_and_ver, vec![bible]) { Ok(s) => { - self.states[i].error = None; Some(s) }, Err(s) => { @@ -283,6 +327,10 @@ impl State { fn view(&self) -> Element { //TODO error message + column![ + button("Cycle Themes") + .on_press(Message::CycleTheme) + .style(button::secondary), scrollable( row![ row((0..self.cols).map(|col_index| { @@ -312,7 +360,7 @@ impl State { button("Delete Column") .on_press_with(move || Message::DeleteColumn(col_index)) .style(button::danger), - text(format!("{:?}", self.states[col_index].error)) + text(format!("{}", self.states[col_index].error.clone().unwrap_or(String::new()))) .style(text::danger), ] .spacing(5), @@ -382,6 +430,7 @@ impl State { .spacing(5), ) .direction(Direction::Horizontal(Scrollbar::new())) + ] .into() } }