diff --git a/Cargo.toml b/Cargo.toml index c2b726c..2fbd135 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,4 +7,5 @@ edition = "2021" [dependencies] epub = "1.2.2" +ncurses = "5.101.0" soup = "0.5.1" diff --git a/src/html_module.rs b/src/html_module.rs index 51d92b7..e80b9b5 100644 --- a/src/html_module.rs +++ b/src/html_module.rs @@ -4,7 +4,7 @@ Language: Rustc 1.69.0 ide: CLion Operating system: Fedora 38/WSL Purpose: This class is meant to process and return HTML formatted text as strings. -Last edited: 5/19/23 +Last edited: 5/20/23 */ //TODO: I received a warning that soup is going to be incompatible in a future version, as it uses an old version of html5ever. /*Possible solutions: diff --git a/src/main.rs b/src/main.rs index 4e075a4..1ed2a5a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,8 @@ Last edited: 5/19/23 mod html_module; +mod ncurses_module; + use epub::doc::EpubDoc; //library for navigating epubs use std::env; use std::process::exit; @@ -17,14 +19,13 @@ use std::process::exit; //initial function. Reads the ebook passed by argument. //TODO: add visual library to pull up ebooks. fn main() { - - if env::args().len() == 1 { println!("you need to enter a book. Closing program."); } else { let args: Vec = env::args().collect(); let filename = &args[1]; + ncurses_module::main(); epub_func(filename); } } @@ -51,10 +52,19 @@ fn epub_func(epub_file: &str){ let input_size = std::io::stdin().read_line(&mut next_or_last); let input_size_len = input_size.unwrap() - 1; if input_size_len == 1{ + + /* + Was not sure how to compare string to input from .read_line + Instead, I felt that it would be easier to convert it to bytes and + compare the ASCII values. + */ let compare = next_or_last.as_bytes(); + + //If user presses n(for next) goes forward one page. if compare[0] == 110 { page_num = page_num + 1; } + //if user presses b, goes back one page. else if compare[0] == 98 { //if page number equals one then you are at the beginning of the book. if page_num == 1 { @@ -64,6 +74,7 @@ fn epub_func(epub_file: &str){ page_num = page_num - 1; } } + //If user presses q(for quit), exits with status code of 0. else if compare[0] == 113 { println!("quitting..."); exit(0); diff --git a/src/ncurses_module.rs b/src/ncurses_module.rs new file mode 100644 index 0000000..6879789 --- /dev/null +++ b/src/ncurses_module.rs @@ -0,0 +1,16 @@ +/* +Program: Bibliofile +Language: Rustc 1.69.0 +ide: CLion +Operating system: Fedora 38/WSL +Purpose: This module is meant to render the book text within ncurses. +Last edited: 5/20/23 + */ + + +use ncurses; + +pub fn main() { + + println!("If you can read this, you are in the ncurses_module"); +} \ No newline at end of file