diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 612aab9..33dc3e9 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -15,9 +15,8 @@
-
+
-
@@ -42,6 +41,9 @@
+ {
+ "associatedIndex": 5
+}
@@ -69,7 +71,7 @@
"vue.rearranger.settings.migration": "true"
}
}
-
+
@@ -104,10 +106,6 @@
-
-
-
-
@@ -136,7 +134,11 @@
-
+
+
+
+
+ 1687972565061
@@ -180,7 +182,14 @@
1697325795094
-
+
+ 1697339218296
+
+
+
+ 1697339218296
+
+
@@ -215,7 +224,8 @@
-
+
+
diff --git a/src/main.rs b/src/main.rs
index c72c86b..de08c88 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,10 +9,17 @@ Last edited: 10/14/23
mod html_module;
use cursive::views::{Dialog, TextView};
+use cursive::backends::termion::termion;
+use cursive::event;
use epub::doc::EpubDoc; //library for navigating epubs
use std::*;
use std::i32;
+use std::io::stdin;
use std::path::Path;
+use termion::event::{Event, Key};
+use termion::input::TermRead;
+use termion::scroll;
+
//this function will determine if Bibliofile has been opened before. If it has not, it will create a library folder under /opt/bibliofile.
@@ -20,10 +27,11 @@ fn library_exists(){
//if /var/lib/bibliofile/library does not exist, create it.
- let mut library_exist_var = Path::exists("/var/lib/bibliofile/library".as_ref());
+ let library_exist_var = Path::exists("/var/lib/bibliofile/library".as_ref());
if library_exist_var == false{
- fs::create_dir_all("/var/lib/bibliofile/library").expect("Error...could not create library. If this is your first time running Bibliofile, try running with sudo.");
+ fs::create_dir_all("/var/lib/bibliofile/library").expect("Error...could not create library. If this is your first time running Bibliofile, try running with sudo.\n\
+ Keep in mind, this program was designed with *nix systems in mind. Running this on Windows will result in unexpected behavior, as it uses a different file system.");
}
}
@@ -64,21 +72,28 @@ fn screen_func(epub_file: &str){
// Starts the event loop.
siv.run();
+ let c = stdin();
+ for c in stdin().events() {
+ let evt = c.unwrap();
+ match evt {
+ Event::Key(Key::Up) => scroll::Up(1),
-
+ _ => {}
+ }
+ }
}
-
fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, String, i32){
let doc = EpubDoc::new(&epub_file);
assert!(doc.is_ok());
let mut doc = doc.unwrap();
let mut usize_num = *page_num as usize;
- if direction == "next" {
+
+ return if direction == "next" {
usize_num = usize_num + 1;
let title = doc.mdata("title");
@@ -87,10 +102,8 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
let str_content = content.unwrap();
let text = html_module::main(str_content.0);
- return (text, title.unwrap(), usize_num as i32);
- }
-
- else if direction == "last" {
+ (text, title.unwrap(), usize_num as i32)
+ } else if direction == "last" {
usize_num = usize_num - 1;
let title = doc.mdata("title");
@@ -99,9 +112,8 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
let str_content = content.unwrap();
let text = html_module::main(str_content.0);
- return (text, title.unwrap(), usize_num as i32);
- }
- else {
+ (text, title.unwrap(), usize_num as i32)
+ } else {
let title = doc.mdata("title");
doc.set_current_page(usize_num);
@@ -109,7 +121,7 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
let str_content = content.unwrap();
let text = html_module::main(str_content.0);
- return (text, title.unwrap(), usize_num as i32);
+ (text, title.unwrap(), usize_num as i32)
}
}