added ncurses library, module, and documentation.
This commit is contained in:
parent
e5f65f66f9
commit
d70f3aa14a
@ -7,4 +7,5 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
epub = "1.2.2"
|
epub = "1.2.2"
|
||||||
|
ncurses = "5.101.0"
|
||||||
soup = "0.5.1"
|
soup = "0.5.1"
|
||||||
|
@ -4,7 +4,7 @@ Language: Rustc 1.69.0
|
|||||||
ide: CLion
|
ide: CLion
|
||||||
Operating system: Fedora 38/WSL
|
Operating system: Fedora 38/WSL
|
||||||
Purpose: This class is meant to process and return HTML formatted text as strings.
|
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.
|
//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:
|
/*Possible solutions:
|
||||||
|
15
src/main.rs
15
src/main.rs
@ -9,6 +9,8 @@ Last edited: 5/19/23
|
|||||||
|
|
||||||
|
|
||||||
mod html_module;
|
mod html_module;
|
||||||
|
mod ncurses_module;
|
||||||
|
|
||||||
use epub::doc::EpubDoc; //library for navigating epubs
|
use epub::doc::EpubDoc; //library for navigating epubs
|
||||||
use std::env;
|
use std::env;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
@ -17,14 +19,13 @@ use std::process::exit;
|
|||||||
//initial function. Reads the ebook passed by argument.
|
//initial function. Reads the ebook passed by argument.
|
||||||
//TODO: add visual library to pull up ebooks.
|
//TODO: add visual library to pull up ebooks.
|
||||||
fn main() {
|
fn main() {
|
||||||
|
|
||||||
|
|
||||||
if env::args().len() == 1 {
|
if env::args().len() == 1 {
|
||||||
println!("you need to enter a book. Closing program.");
|
println!("you need to enter a book. Closing program.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
let filename = &args[1];
|
let filename = &args[1];
|
||||||
|
ncurses_module::main();
|
||||||
epub_func(filename);
|
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 = std::io::stdin().read_line(&mut next_or_last);
|
||||||
let input_size_len = input_size.unwrap() - 1;
|
let input_size_len = input_size.unwrap() - 1;
|
||||||
if input_size_len == 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();
|
let compare = next_or_last.as_bytes();
|
||||||
|
|
||||||
|
//If user presses n(for next) goes forward one page.
|
||||||
if compare[0] == 110 {
|
if compare[0] == 110 {
|
||||||
page_num = page_num + 1;
|
page_num = page_num + 1;
|
||||||
}
|
}
|
||||||
|
//if user presses b, goes back one page.
|
||||||
else if compare[0] == 98 {
|
else if compare[0] == 98 {
|
||||||
//if page number equals one then you are at the beginning of the book.
|
//if page number equals one then you are at the beginning of the book.
|
||||||
if page_num == 1 {
|
if page_num == 1 {
|
||||||
@ -64,6 +74,7 @@ fn epub_func(epub_file: &str){
|
|||||||
page_num = page_num - 1;
|
page_num = page_num - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//If user presses q(for quit), exits with status code of 0.
|
||||||
else if compare[0] == 113 {
|
else if compare[0] == 113 {
|
||||||
println!("quitting...");
|
println!("quitting...");
|
||||||
exit(0);
|
exit(0);
|
||||||
|
16
src/ncurses_module.rs
Normal file
16
src/ncurses_module.rs
Normal file
@ -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");
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user