Merge branch 'master' of https://git.oliveratkinson.net/Oliver/bible
This commit is contained in:
		
							
								
								
									
										2
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitmodules
									
									
									
									
										vendored
									
									
								
							@@ -3,4 +3,4 @@
 | 
				
			|||||||
	url = https://github.com/openscriptures/HebrewLexicon.git
 | 
						url = https://github.com/openscriptures/HebrewLexicon.git
 | 
				
			||||||
[submodule "Holy-Bible-XML-Format"]
 | 
					[submodule "Holy-Bible-XML-Format"]
 | 
				
			||||||
	path = 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
 | 
				
			||||||
 
 | 
				
			|||||||
 Submodule Holy-Bible-XML-Format updated: 69ac8b94c9...7413606dd5
									
								
							
							
								
								
									
										12
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								README.md
									
									
									
									
									
								
							@@ -1,4 +1,4 @@
 | 
				
			|||||||
# cli bible
 | 
					# Bible
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Important Links
 | 
					## Important Links
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -12,3 +12,13 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
[AndBible's formats](https://github.com/AndBible/and-bible/wiki/Supported-3rd-party-module-formats)
 | 
					[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
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										69
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								src/main.rs
									
									
									
									
									
								
							@@ -46,20 +46,16 @@ fn main() -> iced::Result {
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // THEMES
 | 
					 | 
				
			||||||
    //    Dark - KanagawaDragon
 | 
					 | 
				
			||||||
    //    Default - Nord
 | 
					 | 
				
			||||||
    //    Light - TokyoNightLight
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // GUI
 | 
					    // GUI
 | 
				
			||||||
    iced::application("Bible Study", State::update, State::view)
 | 
					    iced::application("Bible Study", State::update, State::view)
 | 
				
			||||||
        .subscription(State::subscription)
 | 
					        .subscription(State::subscription)
 | 
				
			||||||
        .theme(|_| Theme::Nord)
 | 
					        .theme(State::theme)
 | 
				
			||||||
        .run()
 | 
					        .run()
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[derive(Debug, Clone)]
 | 
					#[derive(Debug, Clone)]
 | 
				
			||||||
enum Message {
 | 
					enum Message {
 | 
				
			||||||
 | 
					    CycleTheme,
 | 
				
			||||||
    BibleSearchInput(usize, String),
 | 
					    BibleSearchInput(usize, String),
 | 
				
			||||||
    BibleSelected(usize, String),
 | 
					    BibleSelected(usize, String),
 | 
				
			||||||
    BibleSearchSubmit(usize),
 | 
					    BibleSearchSubmit(usize),
 | 
				
			||||||
@@ -74,6 +70,27 @@ enum Message {
 | 
				
			|||||||
    RecievedEvent(Event),
 | 
					    RecievedEvent(Event),
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					impl Message {
 | 
				
			||||||
 | 
					    fn get_col_idx(&self) -> Option<usize> {
 | 
				
			||||||
 | 
					        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 {
 | 
					struct ColState {
 | 
				
			||||||
    selected_file: Option<String>,
 | 
					    selected_file: Option<String>,
 | 
				
			||||||
    bible_selected: Option<bible::Bible>,
 | 
					    bible_selected: Option<bible::Bible>,
 | 
				
			||||||
@@ -109,6 +126,10 @@ struct State {
 | 
				
			|||||||
    states: Vec<ColState>,
 | 
					    states: Vec<ColState>,
 | 
				
			||||||
    cols: usize,
 | 
					    cols: usize,
 | 
				
			||||||
    tab_index: Option<i32>,
 | 
					    tab_index: Option<i32>,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    theme_idx: usize,
 | 
				
			||||||
 | 
					    themes: [Theme; 3],
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Default for State {
 | 
					impl Default for State {
 | 
				
			||||||
@@ -140,19 +161,45 @@ impl Default for State {
 | 
				
			|||||||
            states: vec![ColState::default()],
 | 
					            states: vec![ColState::default()],
 | 
				
			||||||
            cols: 1,
 | 
					            cols: 1,
 | 
				
			||||||
            tab_index: None,
 | 
					            tab_index: None,
 | 
				
			||||||
 | 
					            // THEMES
 | 
				
			||||||
 | 
					            //    Dark - KanagawaDragon
 | 
				
			||||||
 | 
					            //    Default - Nord
 | 
				
			||||||
 | 
					            //    Light - TokyoNightLight
 | 
				
			||||||
 | 
					            theme_idx: 0,
 | 
				
			||||||
 | 
					            themes: [
 | 
				
			||||||
 | 
					                Theme::KanagawaDragon,
 | 
				
			||||||
 | 
					                Theme::Nord,
 | 
				
			||||||
 | 
					                Theme::TokyoNightLight
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl State {
 | 
					impl State {
 | 
				
			||||||
 | 
					    fn theme(&self) -> Theme {
 | 
				
			||||||
 | 
					        self.themes[self.theme_idx].clone()
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn subscription(&self) -> Subscription<Message> {
 | 
					    fn subscription(&self) -> Subscription<Message> {
 | 
				
			||||||
        event::listen().map(Message::RecievedEvent)
 | 
					        event::listen().map(Message::RecievedEvent)
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn update(&mut self, msg: Message) -> Task<Message> {
 | 
					    fn update(&mut self, msg: Message) -> Task<Message> {
 | 
				
			||||||
 | 
					        // clear error messages
 | 
				
			||||||
 | 
					        if let Some(idx) = msg.get_col_idx() {
 | 
				
			||||||
 | 
					            self.states[idx].error = None
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        // match normal messages
 | 
					        // match normal messages
 | 
				
			||||||
        match msg {
 | 
					        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) => {
 | 
					            Message::RecievedEvent(event) => {
 | 
				
			||||||
                if let Event::Keyboard(kbd) = event {
 | 
					                if let Event::Keyboard(kbd) = event {
 | 
				
			||||||
                    if let iced::keyboard::Event::KeyReleased {key, modifiers, ..} = kbd {
 | 
					                    if let iced::keyboard::Event::KeyReleased {key, modifiers, ..} = kbd {
 | 
				
			||||||
@@ -163,7 +210,6 @@ impl State {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                                    // 2 because two buttons on each col
 | 
					                                    // 2 because two buttons on each col
 | 
				
			||||||
                                    let new_idx = new_idx.clamp(0, (self.cols*2) as i32 -1);
 | 
					                                    let new_idx = new_idx.clamp(0, (self.cols*2) as i32 -1);
 | 
				
			||||||
 | 
					 | 
				
			||||||
                                    self.tab_index = Some(new_idx);
 | 
					                                    self.tab_index = Some(new_idx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                    let id = format!("tabId-{}", 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.
 | 
					                                // the Bible is held in memory in it's own variable.
 | 
				
			||||||
                                self.states[i].selected_file = Some(format!("{bible}"));
 | 
					                                self.states[i].selected_file = Some(format!("{bible}"));
 | 
				
			||||||
                                self.states[i].bible_selected = Some(bible);
 | 
					                                self.states[i].bible_selected = Some(bible);
 | 
				
			||||||
                                self.states[i].error = None;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                            Err(err) => {
 | 
					                            Err(err) => {
 | 
				
			||||||
@@ -236,7 +281,6 @@ impl State {
 | 
				
			|||||||
                {
 | 
					                {
 | 
				
			||||||
                    self.states[i].scripture_body = match bible::get(book, chap_and_ver, vec![bible]) {
 | 
					                    self.states[i].scripture_body = match bible::get(book, chap_and_ver, vec![bible]) {
 | 
				
			||||||
                        Ok(s) => {
 | 
					                        Ok(s) => {
 | 
				
			||||||
                            self.states[i].error = None;
 | 
					 | 
				
			||||||
                            Some(s)
 | 
					                            Some(s)
 | 
				
			||||||
                        },
 | 
					                        },
 | 
				
			||||||
                        Err(s) => {
 | 
					                        Err(s) => {
 | 
				
			||||||
@@ -283,6 +327,10 @@ impl State {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    fn view(&self) -> Element<Message> {
 | 
					    fn view(&self) -> Element<Message> {
 | 
				
			||||||
        //TODO error message
 | 
					        //TODO error message
 | 
				
			||||||
 | 
					        column![
 | 
				
			||||||
 | 
					            button("Cycle Themes")
 | 
				
			||||||
 | 
					                .on_press(Message::CycleTheme)
 | 
				
			||||||
 | 
					                .style(button::secondary),
 | 
				
			||||||
        scrollable(
 | 
					        scrollable(
 | 
				
			||||||
            row![
 | 
					            row![
 | 
				
			||||||
                row((0..self.cols).map(|col_index| {
 | 
					                row((0..self.cols).map(|col_index| {
 | 
				
			||||||
@@ -312,7 +360,7 @@ impl State {
 | 
				
			|||||||
                            button("Delete Column")
 | 
					                            button("Delete Column")
 | 
				
			||||||
                                .on_press_with(move || Message::DeleteColumn(col_index))
 | 
					                                .on_press_with(move || Message::DeleteColumn(col_index))
 | 
				
			||||||
                                .style(button::danger),
 | 
					                                .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),
 | 
					                                .style(text::danger),
 | 
				
			||||||
                        ]
 | 
					                        ]
 | 
				
			||||||
                        .spacing(5),
 | 
					                        .spacing(5),
 | 
				
			||||||
@@ -382,6 +430,7 @@ impl State {
 | 
				
			|||||||
            .spacing(5),
 | 
					            .spacing(5),
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
        .direction(Direction::Horizontal(Scrollbar::new()))
 | 
					        .direction(Direction::Horizontal(Scrollbar::new()))
 | 
				
			||||||
 | 
					        ]
 | 
				
			||||||
        .into()
 | 
					        .into()
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user