From 0c231d8fed2a7ff2d9fc317e6c970268efcf09ed Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 2 Sep 2023 15:21:36 -0500 Subject: [PATCH] - Full Terminal Size now used - Still working on getting newlines working --- .idea/workspace.xml | 17 +++++++++-------- src/main.rs | 25 +++++++++---------------- 2 files changed, 18 insertions(+), 24 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index a569047..f1aa482 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -3,6 +3,9 @@ + { + "useNewFormat": true +} @@ -14,7 +17,6 @@ - - + - - - - - @@ -124,6 +122,9 @@ + + + 1687972565061 diff --git a/src/main.rs b/src/main.rs index 1d73576..c2bf961 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,7 +14,7 @@ use epub::doc::EpubDoc; //library for navigating epubs use std::*; use std::path::Path; use std::process::exit; -use tuikit::term::{Term, TermHeight}; +use tuikit::term::{Term}; 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. @@ -33,7 +33,7 @@ fn library_exists(){ //initial function. Reads the ebook passed by argument. //TODO: add visual library to pull up ebooks. fn main() { - library_exists(); + //library_exists(); if env::args().len() == 1 { println!("you need to enter a book. Closing program."); } @@ -51,15 +51,12 @@ fn epub_func(epub_file: &str){ let doc = EpubDoc::new(&epub_file); 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 term: Term<()> = Term::with_height(TermHeight::Percent(90)).unwrap(); - 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; @@ -68,6 +65,7 @@ fn epub_func(epub_file: &str){ //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, @@ -76,18 +74,13 @@ fn epub_func(epub_file: &str){ _ => {} } doc.set_current_page(page_num); - let attr = Attr{ fg: Color::WHITE, ..Attr::default() }; + let content = doc.get_current_str(); let str_content = content.unwrap(); let text = html_module::main(str_content.0); - let _ = term.print(1, 0, &*text); - //let _ = term.set_cursor(0, 0); + + let _ = term.print(2, 0, &text); let _ = term.present(); - //let _ = term.clear(); - } -} - - - +} \ No newline at end of file