From af933bbc0b743797a7e65e5cf9590383ecae4d31 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Sat, 14 Oct 2023 18:23:13 -0500 Subject: [PATCH] Created initial display --- .idea/workspace.xml | 21 ++++++++++++++++----- Cargo.toml | 2 +- src/main.rs | 44 ++++++++------------------------------------ 3 files changed, 25 insertions(+), 42 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 26e3495..be60bd5 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -15,8 +15,9 @@ - + + @@ -187,7 +197,8 @@ - diff --git a/Cargo.toml b/Cargo.toml index 682c24b..01dc0c3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +cursive = "0.20.0" epub = "2.0.0" scraper = "*" -tuikit = "0.5.0" diff --git a/src/main.rs b/src/main.rs index e305095..1406f88 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,8 +14,8 @@ use epub::doc::EpubDoc; //library for navigating epubs use std::*; use std::path::Path; use std::process::exit; -use tuikit::term::{Term}; -use tuikit::prelude::*; +use cursive::views::{Dialog, TextView}; + //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(){ @@ -53,49 +53,21 @@ fn epub_func(epub_file: &str){ assert!(doc.is_ok()); let mut doc = doc.unwrap(); - let term: Term<()> = Term::new().unwrap(); - - let _ = term.print(1, 0, "Use the left and right button to turn the page.\nUp and down scrolls. Press escape or q to quit."); - let mut page_num = 1; + let title = doc.mdata("title"); - - - //If letter q pressed, closes program. - while let Ok(ev) = term.poll_event() { - let (width, height) = term.term_size().unwrap(); - - match ev { - 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, - _ => {} - } - //This is a really hacky way of doing this. - //TODO: Remember to make a more elegant way of handling stack underflow. - if(page_num <= 0){ doc.set_current_page(1); page_num = 1; let content = doc.get_current_str(); let str_content = content.unwrap(); let text = html_module::main(str_content.0); - let _ = term.set_cursor(1, 1); - let _ = term.print(2, 2, &text); - let _ = term.present(); - } - else { - doc.set_current_page(page_num); + let mut siv = cursive::default(); + siv.add_layer(Dialog::around(TextView::new(text)) + .title(title.unwrap()) + .button("Quit", |s| s.quit())); + siv.run(); - let content = doc.get_current_str(); - let str_content = content.unwrap(); - let text = html_module::main(str_content.0); - let _ = term.set_cursor(1, 1); - - let _ = term.print(2, 2, &text); - let _ = term.present(); - } - } } \ No newline at end of file