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" />
|
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<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$/.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" />
|
<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" />
|
||||||
@ -42,6 +41,9 @@
|
|||||||
<component name="MarkdownSettingsMigration">
|
<component name="MarkdownSettingsMigration">
|
||||||
<option name="stateVersion" value="1" />
|
<option name="stateVersion" value="1" />
|
||||||
</component>
|
</component>
|
||||||
|
<component name="ProjectColorInfo">{
|
||||||
|
"associatedIndex": 5
|
||||||
|
}</component>
|
||||||
<component name="ProjectId" id="2PqGkAwNc4bG190Io9DyS4FEdlC" />
|
<component name="ProjectId" id="2PqGkAwNc4bG190Io9DyS4FEdlC" />
|
||||||
<component name="ProjectViewState">
|
<component name="ProjectViewState">
|
||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
@ -69,7 +71,7 @@
|
|||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}</component>
|
}</component>
|
||||||
<component name="RunManager" selected="Cargo.Run">
|
<component name="RunManager" selected="Cargo.Check">
|
||||||
<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$" />
|
||||||
@ -104,10 +106,6 @@
|
|||||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<list>
|
|
||||||
<item itemvalue="Cargo.Check" />
|
|
||||||
<item itemvalue="Cargo.Run" />
|
|
||||||
</list>
|
|
||||||
</component>
|
</component>
|
||||||
<component name="RustProjectSettings">
|
<component name="RustProjectSettings">
|
||||||
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
||||||
@ -136,7 +134,11 @@
|
|||||||
<workItem from="1697328171250" duration="85000" />
|
<workItem from="1697328171250" duration="85000" />
|
||||||
<workItem from="1697328270424" duration="59000" />
|
<workItem from="1697328270424" duration="59000" />
|
||||||
<workItem from="1697328349082" duration="212000" />
|
<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>
|
||||||
<task id="LOCAL-00001" summary="Commit to scraper_framework branch - changing framework from Soup to Scraper - removed ncurses library. Will use different library instead.">
|
<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>
|
<created>1687972565061</created>
|
||||||
@ -180,7 +182,14 @@
|
|||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1697325795094</updated>
|
<updated>1697325795094</updated>
|
||||||
</task>
|
</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 />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="TypeScriptGeneratedFilesManager">
|
<component name="TypeScriptGeneratedFilesManager">
|
||||||
@ -215,7 +224,8 @@
|
|||||||
<MESSAGE value=" - Full Terminal Size now used - Still working on getting newlines working" />
|
<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="Fixed stack underflow bug. Must find more elegant solution later." />
|
||||||
<MESSAGE value="Created initial display" />
|
<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>
|
||||||
<component name="XSLT-Support.FileAssociations.UIState">
|
<component name="XSLT-Support.FileAssociations.UIState">
|
||||||
<expand />
|
<expand />
|
||||||
|
38
src/main.rs
38
src/main.rs
@ -9,10 +9,17 @@ Last edited: 10/14/23
|
|||||||
|
|
||||||
mod html_module;
|
mod html_module;
|
||||||
use cursive::views::{Dialog, TextView};
|
use cursive::views::{Dialog, TextView};
|
||||||
|
use cursive::backends::termion::termion;
|
||||||
|
use cursive::event;
|
||||||
use epub::doc::EpubDoc; //library for navigating epubs
|
use epub::doc::EpubDoc; //library for navigating epubs
|
||||||
use std::*;
|
use std::*;
|
||||||
use std::i32;
|
use std::i32;
|
||||||
|
use std::io::stdin;
|
||||||
use std::path::Path;
|
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.
|
//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.
|
//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{
|
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.
|
// Starts the event loop.
|
||||||
siv.run();
|
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());
|
assert!(doc.is_ok());
|
||||||
let mut doc = doc.unwrap();
|
let mut doc = doc.unwrap();
|
||||||
let mut usize_num = *page_num as usize;
|
let mut usize_num = *page_num as usize;
|
||||||
if direction == "next" {
|
|
||||||
|
return if direction == "next" {
|
||||||
usize_num = usize_num + 1;
|
usize_num = usize_num + 1;
|
||||||
let title = doc.mdata("title");
|
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 str_content = content.unwrap();
|
||||||
let text = html_module::main(str_content.0);
|
let text = html_module::main(str_content.0);
|
||||||
|
|
||||||
return (text, title.unwrap(), usize_num as i32);
|
(text, title.unwrap(), usize_num as i32)
|
||||||
}
|
} else if direction == "last" {
|
||||||
|
|
||||||
else if direction == "last" {
|
|
||||||
usize_num = usize_num - 1;
|
usize_num = usize_num - 1;
|
||||||
let title = doc.mdata("title");
|
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 str_content = content.unwrap();
|
||||||
let text = html_module::main(str_content.0);
|
let text = html_module::main(str_content.0);
|
||||||
|
|
||||||
return (text, title.unwrap(), usize_num as i32);
|
(text, title.unwrap(), usize_num as i32)
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
let title = doc.mdata("title");
|
let title = doc.mdata("title");
|
||||||
|
|
||||||
doc.set_current_page(usize_num);
|
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 str_content = content.unwrap();
|
||||||
let text = html_module::main(str_content.0);
|
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