- figured out TUIkit printing

This commit is contained in:
Daniel Redd Jones 2023-07-24 18:36:08 -05:00
parent 2fe2421e6d
commit 3d8bc47cf3
2 changed files with 19 additions and 42 deletions

View File

@ -7,7 +7,6 @@ edition = "2021"
[dependencies]
epub = "2.0.0"
ncurses = "5.101.0"
scraper = "0.17.1"
scraper = "*"
tuikit = "0.5.0"

View File

@ -14,6 +14,8 @@ mod html_module;
use epub::doc::EpubDoc; //library for navigating epubs
use std::env;
use std::process::exit;
use tuikit::term::{Term, TermHeight};
use tuikit::prelude::*;
//initial function. Reads the ebook passed by argument.
@ -38,55 +40,31 @@ fn epub_func(epub_file: &str){
assert!(doc.is_ok());
let mut doc = doc.unwrap();
let term: Term<()> = Term::with_height(TermHeight::Percent(90)).unwrap();
let _ = term.clear();
let _ = term.print(0, 0, "Hello world!");
let _ = term.present();
/*
let mut next_or_last = String::new();
let mut page_num = 1;
let is_reading = true;
while is_reading == true {
let mut next_or_last = String::new();
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);
println!("{}", text);
let input_size = std::io::stdin().read_line(&mut next_or_last);
let input_size_len = input_size.unwrap() - 1;
if input_size_len == 1{
/*
Was not sure how to compare string to input from .read_line
Instead, I felt that it would be easier to convert it to bytes and
compare the ASCII values.
*/
let compare = next_or_last.as_bytes();
//If user presses n(for next) goes forward one page.
if compare[0] == 110 {
page_num = page_num + 1;
}
//if user presses b, goes back one page.
else if compare[0] == 98 {
//if page number equals one then you are at the beginning of the book.
if page_num == 1 {
println!("at beginning of book.");
}
else {
page_num = page_num - 1;
}
}
//If user presses q(for quit), exits with status code of 0.
else if compare[0] == 113 {
println!("quitting...");
exit(0);
}
else {
println!("did not understand command.");
}
}
else {
println!("Do not understand input. Try again.");
}
}
}*/
}