bibliofile/src/main.rs

79 lines
1.7 KiB
Rust
Raw Normal View History

/*
Program: Bibliofile
2023-07-24 23:40:33 +00:00
Language: Rustc 1.71.0
ide: CLion
Operating system: Fedora 38/WSL
Purpose: TUI-based ereader and library manager for Linux terminal environments.
2023-07-24 23:40:33 +00:00
Last edited: 7/24/23
*/
//this is a test change to see if gitea is accepting pushes.
mod html_module;
use epub::doc::EpubDoc; //library for navigating epubs
use std::env;
use std::process::exit;
2023-07-24 23:36:08 +00:00
use tuikit::term::{Term, TermHeight};
use tuikit::prelude::*;
//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<String> = env::args().collect();
let filename = &args[1];
epub_func(filename);
}
}
//parses epub files
fn epub_func(epub_file: &str){
let doc = EpubDoc::new(&epub_file);
assert!(doc.is_ok());
let mut doc = doc.unwrap();
2023-07-24 23:36:08 +00:00
let term: Term<()> = Term::with_height(TermHeight::Percent(90)).unwrap();
let _ = term.clear();
let _ = term.print(0, 0, "Hello world!");
let _ = term.present();
2023-07-24 23:40:33 +00:00
let mut page_num = 1;
let is_reading = true;
2023-07-24 23:40:33 +00:00
//If letter q pressed, closes program.
while let Ok(ev) = term.poll_event() {
let _ = term.clear();
match ev {
Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break,
_ => {}
}
2023-07-24 23:36:08 +00:00
2023-07-24 23:40:33 +00:00
/* while is_reading == true {
2023-07-24 23:36:08 +00:00
doc.set_current_page(page_num);
let content = doc.get_current_str();
let str_content = content.unwrap();
let text = html_module::main(str_content.0);
2023-07-24 23:36:08 +00:00
}*/
2023-07-24 23:40:33 +00:00
}
}