Created initial display

This commit is contained in:
Daniel Jones 2023-10-14 18:23:13 -05:00
parent 84f86e1d77
commit af933bbc0b
3 changed files with 25 additions and 42 deletions

View File

@ -15,8 +15,9 @@
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
</component>
<component name="ChangeListManager">
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment=" - Full Terminal Size now used&#10; - Still working on getting newlines working">
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="Fixed stack underflow bug. Must find more elegant solution later.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
@ -56,7 +57,7 @@
"cidr.known.project.marker": "true",
"git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true",
"last_opened_file_path": "D:/Assembly/art_of_64bit_assembly_projects",
"last_opened_file_path": "/home/dan/CLionProjects/bibliofile",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
@ -124,7 +125,9 @@
<workItem from="1689861266305" duration="5017000" />
<workItem from="1693679525485" duration="40000" />
<workItem from="1693679597473" duration="599000" />
<workItem from="1693680405017" duration="6526000" />
<workItem from="1693680405017" duration="7265000" />
<workItem from="1693876306734" duration="49000" />
<workItem from="1697324576800" duration="1175000" />
</task>
<task id="LOCAL-00001" summary="Commit to scraper_framework branch&#10;&#10; - changing framework from Soup to Scraper&#10; - removed ncurses library. Will use different library instead.">
<created>1687972565061</created>
@ -154,7 +157,14 @@
<option name="project" value="LOCAL" />
<updated>1693686100048</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="Fixed stack underflow bug. Must find more elegant solution later.">
<created>1693686989198</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1693686989198</updated>
</task>
<option name="localTasksCounter" value="6" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -187,7 +197,8 @@
<MESSAGE value="Commit to scraper_framework branch&#10;&#10; - changing framework from Soup to Scraper&#10; - removed ncurses library. Will use different library instead." />
<MESSAGE value="- Can now format HTML&#10;- No longer returns to main.rs. Main function in html_module.rs now reads to console locally." />
<MESSAGE value=" - Full Terminal Size now used&#10; - Still working on getting newlines working" />
<option name="LAST_COMMIT_MESSAGE" value=" - Full Terminal Size now used&#10; - Still working on getting newlines working" />
<MESSAGE value="Fixed stack underflow bug. Must find more elegant solution later." />
<option name="LAST_COMMIT_MESSAGE" value="Fixed stack underflow bug. Must find more elegant solution later." />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />

View File

@ -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"

View File

@ -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();
}
}
}