- 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"> <component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="CMakePresetLoader">{
&quot;useNewFormat&quot;: true
}</component>
<component name="CMakeSettings"> <component name="CMakeSettings">
<configurations> <configurations>
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" /> <configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
@ -14,7 +17,6 @@
<component name="ChangeListManager"> <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."> <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$/.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" /> <change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
@ -62,11 +64,11 @@
"org.rust.cargo.project.model.PROJECT_DISCOVERY": "true", "org.rust.cargo.project.model.PROJECT_DISCOVERY": "true",
"org.rust.disableDetachedFileInspectionD:/bibliofile/src/html_module.rs": "true", "org.rust.disableDetachedFileInspectionD:/bibliofile/src/html_module.rs": "true",
"org.rust.disableDetachedFileInspectionD:/bibliofile/src/main.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" "vue.rearranger.settings.migration": "true"
} }
}]]></component> }]]></component>
<component name="RunManager" selected="Cargo.Check"> <component name="RunManager" selected="Cargo.Run">
<configuration name="Check" type="CargoCommandRunConfiguration" factoryName="Cargo Command" nameIsGenerated="true"> <configuration name="Check" type="CargoCommandRunConfiguration" factoryName="Cargo Command" nameIsGenerated="true">
<option name="command" value="check" /> <option name="command" value="check" />
<option name="workingDirectory" value="file://$PROJECT_DIR$" /> <option name="workingDirectory" value="file://$PROJECT_DIR$" />
@ -101,13 +103,9 @@
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" /> <option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
</method> </method>
</configuration> </configuration>
<list>
<item itemvalue="Cargo.Run" />
<item itemvalue="Cargo.Check" />
</list>
</component> </component>
<component name="RustProjectSettings"> <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>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" /> <component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager"> <component name="TaskManager">
@ -124,6 +122,9 @@
<workItem from="1687970763540" duration="4628000" /> <workItem from="1687970763540" duration="4628000" />
<workItem from="1689824866342" duration="40000" /> <workItem from="1689824866342" duration="40000" />
<workItem from="1689861266305" duration="5017000" /> <workItem from="1689861266305" duration="5017000" />
<workItem from="1693679525485" duration="40000" />
<workItem from="1693679597473" duration="599000" />
<workItem from="1693680405017" duration="5602000" />
</task> </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."> <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> <created>1687972565061</created>

View File

@ -14,7 +14,7 @@ use epub::doc::EpubDoc; //library for navigating epubs
use std::*; use std::*;
use std::path::Path; use std::path::Path;
use std::process::exit; use std::process::exit;
use tuikit::term::{Term, TermHeight}; use tuikit::term::{Term};
use tuikit::prelude::*; 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. //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. //initial function. Reads the ebook passed by argument.
//TODO: add visual library to pull up ebooks. //TODO: add visual library to pull up ebooks.
fn main() { fn main() {
library_exists(); //library_exists();
if env::args().len() == 1 { if env::args().len() == 1 {
println!("you need to enter a book. Closing program."); 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); let doc = EpubDoc::new(&epub_file);
assert!(doc.is_ok()); assert!(doc.is_ok());
let mut doc = doc.unwrap(); 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; let mut page_num = 1;
@ -68,6 +65,7 @@ fn epub_func(epub_file: &str){
//If letter q pressed, closes program. //If letter q pressed, closes program.
while let Ok(ev) = term.poll_event() { while let Ok(ev) = term.poll_event() {
let (width, height) = term.term_size().unwrap();
match ev { match ev {
Event::Key(Key::ESC) | Event::Key(Key::Char('q')) => break, 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); doc.set_current_page(page_num);
let attr = Attr{ fg: Color::WHITE, ..Attr::default() };
let content = doc.get_current_str(); let content = doc.get_current_str();
let str_content = content.unwrap(); let str_content = content.unwrap();
let text = html_module::main(str_content.0); 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.present();
//let _ = term.clear();
} }
} }