- Added page turning
TODO: add scrolling and newline support
This commit is contained in:
parent
8cef3a5c8c
commit
227b47f4d3
32
src/main.rs
32
src/main.rs
@ -23,7 +23,7 @@ fn library_exists(){
|
|||||||
|
|
||||||
//if /var/lib/bibliofile/library does not exist, create it.
|
//if /var/lib/bibliofile/library does not exist, create it.
|
||||||
let mut library_exist_var = Path::exists("/var/lib/bibliofile/library".as_ref());
|
let mut library_exist_var = Path::exists("/var/lib/bibliofile/library".as_ref());
|
||||||
println!("{}", library_exist_var);
|
|
||||||
if library_exist_var == false{
|
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.");
|
||||||
}
|
}
|
||||||
@ -51,39 +51,41 @@ fn epub_func(epub_file: &str){
|
|||||||
|
|
||||||
let doc = EpubDoc::new(&epub_file);
|
let doc = EpubDoc::new(&epub_file);
|
||||||
assert!(doc.is_ok());
|
assert!(doc.is_ok());
|
||||||
|
|
||||||
let mut doc = doc.unwrap();
|
let mut doc = doc.unwrap();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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, "Use the left and right button to turn the page.\nUp and down scrolls. Press escape or q to quit.");
|
||||||
|
let _ = term.present();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
let mut page_num = 1;
|
let mut page_num = 1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//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();
|
|
||||||
match ev {
|
match ev {
|
||||||
Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break,
|
Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break,
|
||||||
|
Event::Key(Key::Right) => page_num = page_num + 1,
|
||||||
|
Event::Key(Key::Left) => page_num = page_num - 1,
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
doc.set_current_page(page_num);
|
doc.set_current_page(page_num);
|
||||||
|
let attr = Attr{ fg: Color::WHITE, ..Attr::default() };
|
||||||
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.print(1, 0, &*text);
|
||||||
|
//let _ = term.set_cursor(0, 0);
|
||||||
let _ = term.present();
|
let _ = term.present();
|
||||||
|
|
||||||
|
//let _ = term.clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user