- Full Terminal Size now used

- Still working on getting newlines working
This commit is contained in:
dan 2023-09-02 15:21:36 -05:00
parent 227b47f4d3
commit 0c231d8fed
2 changed files with 18 additions and 24 deletions

View File

@ -3,6 +3,9 @@
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="CMakePresetLoader">{
&quot;useNewFormat&quot;: true
}</component>
<component name="CMakeSettings">
<configurations>
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
@ -14,7 +17,6 @@
<component name="ChangeListManager">
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="- Can now format HTML&#10;- No longer returns to main.rs. Main function in html_module.rs now reads to console locally.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/html_module.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/html_module.rs" 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" />
@ -62,11 +64,11 @@
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
"org.rust.disableDetachedFileInspectionD:/bibliofile/src/html_module.rs": "true",
"org.rust.disableDetachedFileInspectionD:/bibliofile/src/main.rs": "true",
"settings.editor.selected.configurable": "org.jetbrains.plugins.github.ui.GithubSettingsConfigurable",
"settings.editor.selected.configurable": "language.rust",
"vue.rearranger.settings.migration": "true"
}
}]]></component>
<component name="RunManager" selected="Cargo.Check">
<component name="RunManager" selected="Cargo.Run">
<configuration name="Check" type="CargoCommandRunConfiguration" factoryName="Cargo Command" nameIsGenerated="true">
<option name="command" value="check" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
@ -101,13 +103,9 @@
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Cargo.Run" />
<item itemvalue="Cargo.Check" />
</list>
</component>
<component name="RustProjectSettings">
<option name="toolchainHomeDirectory" value="//wsl$/Ubuntu-22.04/home/jonesd/.cargo/bin" />
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
@ -124,6 +122,9 @@
<workItem from="1687970763540" duration="4628000" />
<workItem from="1689824866342" duration="40000" />
<workItem from="1689861266305" duration="5017000" />
<workItem from="1693679525485" duration="40000" />
<workItem from="1693679597473" duration="599000" />
<workItem from="1693680405017" duration="5602000" />
</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>

View File

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