Merge branch 'master' of https://git.oliveratkinson.net/Oliver/bible
This commit is contained in:
commit
e487bb9a69
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -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
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 69ac8b94c9781f25483905ee08192ee4bf982317
|
||||
Subproject commit 7413606dd54f4fb2500f0a6174d0e8b832850392
|
12
README.md
12
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
|
||||
|
||||
|
69
src/main.rs
69
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<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 {
|
||||
selected_file: Option<String>,
|
||||
bible_selected: Option<bible::Bible>,
|
||||
@ -109,6 +126,10 @@ struct State {
|
||||
states: Vec<ColState>,
|
||||
cols: usize,
|
||||
tab_index: Option<i32>,
|
||||
|
||||
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<Message> {
|
||||
event::listen().map(Message::RecievedEvent)
|
||||
}
|
||||
|
||||
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 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<Message> {
|
||||
//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()
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user