firgured out scrolling
This commit is contained in:
parent
7bb7b3deb1
commit
4da4809969
8
.idea/bibliofile.iml
Normal file
8
.idea/bibliofile.iml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="CPP_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/bibliofile.iml" filepath="$PROJECT_DIR$/.idea/bibliofile.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -49,28 +49,28 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"cf.first.check.clang-format": "false",
|
||||
"cidr.known.project.marker": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"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)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"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": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"RunOnceActivity.OpenProjectViewOnStart": "true",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||
"WebServerToolWindowFactoryState": "false",
|
||||
"cf.first.check.clang-format": "false",
|
||||
"cidr.known.project.marker": "true",
|
||||
"git-widget-placeholder": "master",
|
||||
"ignore.virus.scanning.warn.message": "true",
|
||||
"last_opened_file_path": "//wsl$/Ubuntu-22.04/home/jonesd/bibliofile",
|
||||
"node.js.detected.package.eslint": "true",
|
||||
"node.js.detected.package.tslint": "true",
|
||||
"node.js.selected.package.eslint": "(autodetect)",
|
||||
"node.js.selected.package.tslint": "(autodetect)",
|
||||
"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": "preferences.pluginManager",
|
||||
"vue.rearranger.settings.migration": "true"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RunManager" selected="Cargo.Check">
|
||||
<configuration name="Check" type="CargoCommandRunConfiguration" factoryName="Cargo Command" nameIsGenerated="true">
|
||||
<option name="command" value="check" />
|
||||
@ -139,6 +139,7 @@
|
||||
<workItem from="1697344288791" duration="562000" />
|
||||
<workItem from="1697344966098" duration="165000" />
|
||||
<workItem from="1697345194146" duration="1214000" />
|
||||
<workItem from="1698172797400" duration="4440000" />
|
||||
</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>
|
||||
@ -196,6 +197,11 @@
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
<option name="OPEN_GENERIC_TABS">
|
||||
<map>
|
||||
<entry key="bf7340ba-b072-4b3b-9ffa-ee490e55e871" value="TOOL_WINDOW" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="TAB_STATES">
|
||||
<map>
|
||||
<entry key="MAIN">
|
||||
@ -215,6 +221,11 @@
|
||||
</State>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="bf7340ba-b072-4b3b-9ffa-ee490e55e871">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
|
3
meditations.epub:Zone.Identifier
Normal file
3
meditations.epub:Zone.Identifier
Normal file
@ -0,0 +1,3 @@
|
||||
[ZoneTransfer]
|
||||
ZoneId=3
|
||||
HostUrl=about:internet
|
71
src/main.rs
71
src/main.rs
@ -9,16 +9,14 @@ Last edited: 10/14/23
|
||||
|
||||
mod html_module;
|
||||
use cursive::views::{Dialog, TextView};
|
||||
use cursive::backends::termion::termion;
|
||||
use cursive::event;
|
||||
use cursive::Cursive;
|
||||
use cursive::view::Scrollable;
|
||||
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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -56,38 +54,34 @@ fn main() {
|
||||
|
||||
//this function manages the screen
|
||||
fn screen_func(epub_file: &str){
|
||||
|
||||
let mut page_num = 1;
|
||||
let textinfo = get_text(epub_file, &page_num, "next");
|
||||
let mut siv = cursive::default();
|
||||
let textinfo = get_init_text(epub_file, &page_num, "next");
|
||||
let text = textinfo.0;
|
||||
let title = textinfo.1;
|
||||
page_num = textinfo.2;
|
||||
|
||||
|
||||
// Creates the cursive root - required for every application.
|
||||
let mut siv = cursive::default();
|
||||
siv.add_global_callback('q', |s| s.quit());
|
||||
|
||||
// Creates a dialog with a single "Quit" button
|
||||
siv.add_layer(Dialog::around(TextView::new(text))
|
||||
.title(title)
|
||||
.button("Quit", |s| s.quit()));
|
||||
.scrollable()
|
||||
.scroll_x(true),
|
||||
);
|
||||
|
||||
// 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),
|
||||
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, String, i32){
|
||||
fn get_text(s: &mut Cursive, epub_file: &str, mut page_num: &i32, direction: &str) -> (String, String, i32) {
|
||||
let doc = EpubDoc::new(&epub_file);
|
||||
assert!(doc.is_ok());
|
||||
let mut doc = doc.unwrap();
|
||||
@ -123,7 +117,44 @@ fn get_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, St
|
||||
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
}
|
||||
}
|
||||
|
||||
fn get_init_text(epub_file: &str, mut page_num: &i32, direction: &str) -> (String, String, i32){
|
||||
let doc = EpubDoc::new(&epub_file);
|
||||
assert!(doc.is_ok());
|
||||
let mut doc = doc.unwrap();
|
||||
let mut usize_num = *page_num as usize;
|
||||
|
||||
return if direction == "next" {
|
||||
usize_num = usize_num + 1;
|
||||
let title = doc.mdata("title");
|
||||
|
||||
doc.set_current_page(usize_num);
|
||||
let content = doc.get_current_str();
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
} else if direction == "last" {
|
||||
usize_num = usize_num - 1;
|
||||
let title = doc.mdata("title");
|
||||
|
||||
doc.set_current_page(usize_num);
|
||||
let content = doc.get_current_str();
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
} else {
|
||||
let title = doc.mdata("title");
|
||||
|
||||
doc.set_current_page(usize_num);
|
||||
let content = doc.get_current_str();
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
|
||||
(text, title.unwrap(), usize_num as i32)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user