- Created library directory with exception check.
- Added page display for TUI
This commit is contained in:
parent
68a862cb5a
commit
8cef3a5c8c
33
src/main.rs
33
src/main.rs
@ -4,23 +4,36 @@ Language: Rustc 1.71.0
|
|||||||
ide: CLion
|
ide: CLion
|
||||||
Operating system: Fedora 38/WSL
|
Operating system: Fedora 38/WSL
|
||||||
Purpose: TUI-based ereader and library manager for Linux terminal environments.
|
Purpose: TUI-based ereader and library manager for Linux terminal environments.
|
||||||
Last edited: 7/24/23
|
Last edited: 7/27/23
|
||||||
*/
|
*/
|
||||||
//this is a test change to see if gitea is accepting pushes.
|
|
||||||
|
|
||||||
mod html_module;
|
mod html_module;
|
||||||
|
|
||||||
|
|
||||||
use epub::doc::EpubDoc; //library for navigating epubs
|
use epub::doc::EpubDoc; //library for navigating epubs
|
||||||
use std::env;
|
use std::*;
|
||||||
|
use std::path::Path;
|
||||||
use std::process::exit;
|
use std::process::exit;
|
||||||
use tuikit::term::{Term, TermHeight};
|
use tuikit::term::{Term, TermHeight};
|
||||||
use tuikit::prelude::*;
|
use tuikit::prelude::*;
|
||||||
|
|
||||||
|
//this function will determine if Bibliofile has been opened before. If it has not, it will create a library folder under /opt/bibliofile.
|
||||||
|
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());
|
||||||
|
println!("{}", library_exist_var);
|
||||||
|
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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
//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() {
|
||||||
|
library_exists();
|
||||||
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.");
|
||||||
}
|
}
|
||||||
@ -44,8 +57,8 @@ fn epub_func(epub_file: &str){
|
|||||||
|
|
||||||
let term: Term<()> = Term::with_height(TermHeight::Percent(90)).unwrap();
|
let term: Term<()> = Term::with_height(TermHeight::Percent(90)).unwrap();
|
||||||
let _ = term.clear();
|
let _ = term.clear();
|
||||||
let _ = term.print(0, 0, "Hello world!");
|
|
||||||
let _ = term.present();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -53,7 +66,7 @@ fn epub_func(epub_file: &str){
|
|||||||
|
|
||||||
|
|
||||||
let mut page_num = 1;
|
let mut page_num = 1;
|
||||||
let is_reading = true;
|
|
||||||
//If letter q pressed, closes program.
|
//If letter q pressed, closes program.
|
||||||
while let Ok(ev) = term.poll_event() {
|
while let Ok(ev) = term.poll_event() {
|
||||||
let _ = term.clear();
|
let _ = term.clear();
|
||||||
@ -62,15 +75,15 @@ fn epub_func(epub_file: &str){
|
|||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* while is_reading == true {
|
|
||||||
|
|
||||||
doc.set_current_page(page_num);
|
doc.set_current_page(page_num);
|
||||||
|
|
||||||
let content = doc.get_current_str();
|
let content = doc.get_current_str();
|
||||||
let str_content = content.unwrap();
|
let str_content = content.unwrap();
|
||||||
let text = html_module::main(str_content.0);
|
let text = html_module::main(str_content.0);
|
||||||
|
let _ = term.print(0, 0, &*text);
|
||||||
}*/
|
let _ = term.present();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user