Working on getting scrolling working so that you can read the whole page
This commit is contained in:
parent
93eadf68c8
commit
7bb7b3deb1
@ -15,9 +15,8 @@
|
||||
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="Created initial display">
|
||||
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="set termion as backend, curses as frontend. setup for new page turning system to accomodate cursive">
|
||||
<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" />
|
||||
@ -42,6 +41,9 @@
|
||||
<component name="MarkdownSettingsMigration">
|
||||
<option name="stateVersion" value="1" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 5
|
||||
}</component>
|
||||
<component name="ProjectId" id="2PqGkAwNc4bG190Io9DyS4FEdlC" />
|
||||
<component name="ProjectViewState">
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
@ -69,7 +71,7 @@
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</component>
|
||||
<component name="RunManager" selected="Cargo.Run">
|
||||
<component name="RunManager" selected="Cargo.Check">
|
||||
<configuration name="Check" type="CargoCommandRunConfiguration" factoryName="Cargo Command" nameIsGenerated="true">
|
||||
<option name="command" value="check" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
@ -104,10 +106,6 @@
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<list>
|
||||
<item itemvalue="Cargo.Check" />
|
||||
<item itemvalue="Cargo.Run" />
|
||||
</list>
|
||||
</component>
|
||||
<component name="RustProjectSettings">
|
||||
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
||||
@ -136,7 +134,11 @@
|
||||
<workItem from="1697328171250" duration="85000" />
|
||||
<workItem from="1697328270424" duration="59000" />
|
||||
<workItem from="1697328349082" duration="212000" />
|
||||
<workItem from="1697328580563" duration="9760000" />
|
||||
<workItem from="1697328580563" duration="14311000" />
|
||||
<workItem from="1697344247977" duration="29000" />
|
||||
<workItem from="1697344288791" duration="562000" />
|
||||
<workItem from="1697344966098" duration="165000" />
|
||||
<workItem from="1697345194146" duration="1214000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Commit to scraper_framework branch - changing framework from Soup to Scraper - removed ncurses library. Will use different library instead.">
|
||||
<created>1687972565061</created>
|
||||
@ -180,7 +182,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1697325795094</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="7" />
|
||||
<task id="LOCAL-00007" summary="set termion as backend, curses as frontend. setup for new page turning system to accomodate cursive">
|
||||
<created>1697339218296</created>
|
||||
<option name="number" value="00007" />
|
||||
<option name="presentableId" value="LOCAL-00007" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1697339218296</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="8" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -215,7 +224,8 @@
|
||||
<MESSAGE value=" - Full Terminal Size now used - Still working on getting newlines working" />
|
||||
<MESSAGE value="Fixed stack underflow bug. Must find more elegant solution later." />
|
||||
<MESSAGE value="Created initial display" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Created initial display" />
|
||||
<MESSAGE value="set termion as backend, curses as frontend. setup for new page turning system to accomodate cursive" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="set termion as backend, curses as frontend. setup for new page turning system to accomodate cursive" />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
38
src/main.rs
38
src/main.rs
@ -9,10 +9,17 @@ Last edited: 10/14/23
|
||||
|
||||
mod html_module;
|
||||
use cursive::views::{Dialog, TextView};
|
||||
use cursive::backends::termion::termion;
|
||||
use cursive::event;
|
||||
use epub::doc::EpubDoc; //library for navigating epubs
|
||||
use std::*;
|
||||
use std::i32;
|
||||
use std::io::stdin;
|
||||
use std::path::Path;
|
||||
use termion::event::{Event, Key};
|
||||
use termion::input::TermRead;
|
||||
use termion::scroll;
|
||||
|
||||
|
||||
|
||||
//this function will determine if Bibliofile has been opened before. If it has not, it will create a library folder under /opt/bibliofile.
|
||||
@ -20,10 +27,11 @@ fn library_exists(){
|
||||
|
||||
|
||||
//if /var/lib/bibliofile/library does not exist, create it.
|
||||
let mut library_exist_var = Path::exists("/var/lib/bibliofile/library".as_ref());
|
||||
let library_exist_var = Path::exists("/var/lib/bibliofile/library".as_ref());
|
||||
|
||||
if library_exist_var == false{
|
||||
fs::create_dir_all("/var/lib/bibliofile/library").expect("Error...could not create library. If this is your first time running Bibliofile, try running with sudo.");
|
||||
fs::create_dir_all("/var/lib/bibliofile/library").expect("Error...could not create library. If this is your first time running Bibliofile, try running with sudo.\n\
|
||||
Keep in mind, this program was designed with *nix systems in mind. Running this on Windows will result in unexpected behavior, as it uses a different file system.");
|
||||
}
|
||||
|
||||
}
|
||||
@ -64,11 +72,17 @@ fn screen_func(epub_file: &str){
|
||||
// Starts the event loop.
|
||||
siv.run();
|
||||
|
||||
let c = stdin();
|
||||
for c in stdin().events() {
|
||||
let evt = c.unwrap();
|
||||
match evt {
|
||||
Event::Key(Key::Up) => scroll::Up(1),
|
||||
|
||||
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -78,7 +92,8 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
|
||||
assert!(doc.is_ok());
|
||||
let mut doc = doc.unwrap();
|
||||
let mut usize_num = *page_num as usize;
|
||||
if direction == "next" {
|
||||
|
||||
return if direction == "next" {
|
||||
usize_num = usize_num + 1;
|
||||
let title = doc.mdata("title");
|
||||
|
||||
@ -87,10 +102,8 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
|
||||
return (text, title.unwrap(), usize_num as i32);
|
||||
}
|
||||
|
||||
else if direction == "last" {
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
} else if direction == "last" {
|
||||
usize_num = usize_num - 1;
|
||||
let title = doc.mdata("title");
|
||||
|
||||
@ -99,9 +112,8 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
|
||||
return (text, title.unwrap(), usize_num as i32);
|
||||
}
|
||||
else {
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
} else {
|
||||
let title = doc.mdata("title");
|
||||
|
||||
doc.set_current_page(usize_num);
|
||||
@ -109,7 +121,7 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
|
||||
return (text, title.unwrap(), usize_num as i32);
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user