Tried a few things out, learned that page_num will outlive s. This causes the program to crash. Because of this, I will have page_num save to a file and open it when needed. That way it will not outlive S, and automatic bookmarking will already be implemented.
Does not run as-is, need to clean up and refactor code to fix the bugs.
This commit is contained in:
parent
2670e6ffd4
commit
c627c95363
@ -15,7 +15,7 @@
|
||||
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="Figured out how to call a function upon pressing a button without throwing an error. Solution: Open the file every time the button is pressed and go to specified page. File outlasts s function, so error called every time function is called.">
|
||||
<list default="true" id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="page turning figured out. Must make get_text recursive so that you can call it again once you are done reading.">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
|
||||
</list>
|
||||
@ -49,28 +49,29 @@
|
||||
<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": "//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 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.disableDetachedFileInspection/home/dan/CLionProjects/bibliofile/src/main.rs": "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" />
|
||||
@ -198,7 +199,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1699028520042</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="9" />
|
||||
<task id="LOCAL-00009" summary="page turning figured out. Must make get_text recursive so that you can call it again once you are done reading.">
|
||||
<option name="closed" value="true" />
|
||||
<created>1699028860277</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1699028860277</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="10" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@ -245,7 +254,8 @@
|
||||
<MESSAGE value="Created initial display" />
|
||||
<MESSAGE value="set termion as backend, curses as frontend. setup for new page turning system to accomodate cursive" />
|
||||
<MESSAGE value="Figured out how to call a function upon pressing a button without throwing an error. Solution: Open the file every time the button is pressed and go to specified page. File outlasts s function, so error called every time function is called." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Figured out how to call a function upon pressing a button without throwing an error. Solution: Open the file every time the button is pressed and go to specified page. File outlasts s function, so error called every time function is called." />
|
||||
<MESSAGE value="page turning figured out. Must make get_text recursive so that you can call it again once you are done reading." />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="page turning figured out. Must make get_text recursive so that you can call it again once you are done reading." />
|
||||
</component>
|
||||
<component name="XSLT-Support.FileAssociations.UIState">
|
||||
<expand />
|
||||
|
10
src/main.rs
10
src/main.rs
@ -78,8 +78,11 @@ fn screen_func(epub_file: &str){
|
||||
|
||||
|
||||
|
||||
//TODO: Because page_num will outlive s, Must write page_num to file and call read it to see what page is needed to be open.
|
||||
//This will also work for placekeeping purposes if another book is opened and you want to return to it
|
||||
|
||||
fn get_text(s: &mut Cursive, mut page_num: &i32, direction: &str) {
|
||||
|
||||
fn get_text(s: &mut Cursive) {
|
||||
s.pop_layer();
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let filename = &args[1];
|
||||
@ -87,14 +90,15 @@ fn get_text(s: &mut Cursive, mut page_num: &i32, direction: &str) {
|
||||
let mut doc = doc.unwrap();
|
||||
let mut usize_num = *page_num as usize;
|
||||
usize_num = usize_num + 1;
|
||||
let title = doc.mdata("title");
|
||||
|
||||
let title = doc.mdata("title");
|
||||
s.add_global_callback('d', move |s| { get_text(s); });
|
||||
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);
|
||||
s.add_layer(Dialog::around(TextView::new(text))
|
||||
.title(title + " page: " + &page_num.to_string())
|
||||
.title(title.unwrap() + " page: " + &usize_num.to_string())
|
||||
.scrollable()
|
||||
.scroll_x(true),
|
||||
);
|
||||
|
Loading…
Reference in New Issue
Block a user