added previous page button and bookmark button. Base functionality completed. Now is time for quality control.
This commit is contained in:
parent
7e29e89a78
commit
5956afc314
22
.github/workflows/rust.yml
vendored
22
.github/workflows/rust.yml
vendored
@ -1,22 +0,0 @@
|
||||
name: Rust
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
pull_request:
|
||||
branches: [ "master" ]
|
||||
|
||||
env:
|
||||
CARGO_TERM_COLOR: always
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Build
|
||||
run: cargo build --verbose
|
||||
- name: Run tests
|
||||
run: cargo test --verbose
|
@ -1,8 +0,0 @@
|
||||
<?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>
|
@ -1,8 +0,0 @@
|
||||
<?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>
|
@ -1,6 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -1,264 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="AutoImportSettings">
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="CMakePresetLoader">{
|
||||
"useNewFormat": true
|
||||
}</component>
|
||||
<component name="CMakeSettings">
|
||||
<configurations>
|
||||
<configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />
|
||||
</configurations>
|
||||
</component>
|
||||
<component name="CargoProjects">
|
||||
<cargoProject FILE="$PROJECT_DIR$/Cargo.toml" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<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>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||
<option name="LAST_RESOLUTION" value="IGNORE" />
|
||||
</component>
|
||||
<component name="ClangdSettings">
|
||||
<option name="formatViaClangd" value="false" />
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_BRANCH_BY_REPOSITORY">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="master" />
|
||||
</map>
|
||||
</option>
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
</component>
|
||||
<component name="MacroExpansionManager">
|
||||
<option name="directoryName" value="3emh3loa" />
|
||||
</component>
|
||||
<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" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<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 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$" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
<configuration name="Run" type="CargoCommandRunConfiguration" factoryName="Cargo Command" nameIsGenerated="true">
|
||||
<option name="command" value="run pg345-images.epub" />
|
||||
<option name="workingDirectory" value="file://$PROJECT_DIR$" />
|
||||
<option name="emulateTerminal" value="false" />
|
||||
<option name="channel" value="DEFAULT" />
|
||||
<option name="requiredFeatures" value="true" />
|
||||
<option name="allFeatures" value="false" />
|
||||
<option name="withSudo" value="false" />
|
||||
<option name="buildTarget" value="REMOTE" />
|
||||
<option name="backtrace" value="SHORT" />
|
||||
<envs />
|
||||
<option name="isRedirectInput" value="false" />
|
||||
<option name="redirectInputPath" value="" />
|
||||
<method v="2">
|
||||
<option name="CARGO.BUILD_TASK_PROVIDER" enabled="true" />
|
||||
</method>
|
||||
</configuration>
|
||||
</component>
|
||||
<component name="RustProjectSettings">
|
||||
<option name="toolchainHomeDirectory" value="$USER_HOME$/.cargo/bin" />
|
||||
</component>
|
||||
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
|
||||
<component name="TaskManager">
|
||||
<task active="true" id="Default" summary="Default task">
|
||||
<changelist id="81820af5-b0ad-4ac7-a939-e3db68fc7214" name="Changes" comment="" />
|
||||
<created>1684177338227</created>
|
||||
<option name="number" value="Default" />
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1684177338227</updated>
|
||||
<workItem from="1684177339283" duration="296000" />
|
||||
<workItem from="1684180154545" duration="927000" />
|
||||
<workItem from="1684181684374" duration="176000" />
|
||||
<workItem from="1684345543022" duration="781000" />
|
||||
<workItem from="1687970763540" duration="4628000" />
|
||||
<workItem from="1689824866342" duration="40000" />
|
||||
<workItem from="1689861266305" duration="5017000" />
|
||||
<workItem from="1693679525485" duration="40000" />
|
||||
<workItem from="1693679597473" duration="599000" />
|
||||
<workItem from="1693680405017" duration="7265000" />
|
||||
<workItem from="1693876306734" duration="49000" />
|
||||
<workItem from="1697324576800" duration="3431000" />
|
||||
<workItem from="1697328049119" duration="41000" />
|
||||
<workItem from="1697328171250" duration="85000" />
|
||||
<workItem from="1697328270424" duration="59000" />
|
||||
<workItem from="1697328349082" duration="212000" />
|
||||
<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" />
|
||||
<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>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1687972565061</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="Commit to scraper_framework branch - changing framework from Soup to Scraper - removed ncurses library. Will use different library instead.">
|
||||
<created>1687972590786</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1687972590786</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="- Can now format HTML - No longer returns to main.rs. Main function in html_module.rs now reads to console locally.">
|
||||
<created>1687974796970</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1687974796970</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary=" - Full Terminal Size now used - Still working on getting newlines working">
|
||||
<created>1693686100048</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1693686100048</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00005" summary="Fixed stack underflow bug. Must find more elegant solution later.">
|
||||
<created>1693686989198</created>
|
||||
<option name="number" value="00005" />
|
||||
<option name="presentableId" value="LOCAL-00005" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1693686989198</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00006" summary="Created initial display">
|
||||
<created>1697325795094</created>
|
||||
<option name="number" value="00006" />
|
||||
<option name="presentableId" value="LOCAL-00006" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1697325795094</updated>
|
||||
</task>
|
||||
<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>
|
||||
<task id="LOCAL-00008" summary="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="closed" value="true" />
|
||||
<created>1699028520042</created>
|
||||
<option name="number" value="00008" />
|
||||
<option name="presentableId" value="LOCAL-00008" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1699028520042</updated>
|
||||
</task>
|
||||
<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">
|
||||
<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">
|
||||
<value>
|
||||
<State>
|
||||
<option name="FILTERS">
|
||||
<map>
|
||||
<entry key="branch">
|
||||
<value>
|
||||
<list>
|
||||
<option value="scraper_framework" />
|
||||
</list>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</State>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="bf7340ba-b072-4b3b-9ffa-ee490e55e871">
|
||||
<value>
|
||||
<State />
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Commit to scraper_framework branch - changing framework from Soup to Scraper - removed ncurses library. Will use different library instead." />
|
||||
<MESSAGE value="- Can now format HTML - No longer returns to main.rs. Main function in html_module.rs now reads to console locally." />
|
||||
<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" />
|
||||
<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." />
|
||||
<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 />
|
||||
<select />
|
||||
</component>
|
||||
</project>
|
@ -1 +1 @@
|
||||
10
|
||||
4
|
1
Dracula_next
Normal file
1
Dracula_next
Normal file
@ -0,0 +1 @@
|
||||
4
|
159
src/main.rs
159
src/main.rs
@ -87,7 +87,7 @@ fn screen_func(epub_file: &str){
|
||||
// Creates a dialog with a single "Quit" button
|
||||
siv.add_layer(Dialog::around(TextView::new(text))
|
||||
.title("Bibliofile")
|
||||
.button("begin", |s| {get_text(s);}),
|
||||
.button("begin", |s| {get_init_text(s);}),
|
||||
);
|
||||
|
||||
// Starts the event loop.
|
||||
@ -117,14 +117,136 @@ fn get_text(s: &mut Cursive) {
|
||||
//gets page number/bookmark
|
||||
let title = doc.mdata("title");
|
||||
let bookmark_file_name = title.clone().unwrap() + "_bookmark";
|
||||
|
||||
let next_page = title.clone().unwrap() + "_next";
|
||||
|
||||
//if bookmark for file exists, continue to open. If not, create the file and try again.
|
||||
if Path::exists(bookmark_file_name.as_ref()){
|
||||
|
||||
let bookmark = fs::read_to_string(bookmark_file_name.clone()).expect("no file found! You kidding me?");
|
||||
let next_page_var = fs::read_to_string(next_page.clone()).expect("no file found!");
|
||||
|
||||
let mut page_num: usize = bookmark
|
||||
let mut page_num: usize = next_page_var
|
||||
.trim()
|
||||
.parse()
|
||||
.expect("not a number");// converts from string to usize
|
||||
|
||||
|
||||
|
||||
page_num = page_num + 1;
|
||||
doc.set_current_page(page_num);
|
||||
let content = doc.get_current_str();
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
let number_title = page_num;
|
||||
|
||||
|
||||
|
||||
let page_string = page_num.to_string();
|
||||
|
||||
//writes where the next page is so that Rust knows where to go
|
||||
fs::write(next_page, page_string.as_bytes()).expect("Unable to write file");
|
||||
|
||||
//refreshed screen layout
|
||||
s.add_layer(Dialog::around(TextView::new(text))
|
||||
.title(title.unwrap() + " page: " + &number_title.to_string())
|
||||
.button("last", |s| {get_last_text(s);})
|
||||
.button("quit", |s| s.quit())
|
||||
.button("bookmark", move |s| {bookmark_func(s, page_num, &bookmark_file_name);})
|
||||
.button("next", |s| {get_text(s);})
|
||||
.scrollable()
|
||||
.scroll_x(true),
|
||||
);
|
||||
}
|
||||
|
||||
else{
|
||||
fs::write(next_page, "1").expect("Unable to write file");
|
||||
get_text(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fn get_last_text(s: &mut Cursive) {
|
||||
|
||||
|
||||
//removes old layer, builds new one
|
||||
s.pop_layer();
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let filename = &args[1];
|
||||
let doc = EpubDoc::new(filename);
|
||||
let mut doc = doc.unwrap();
|
||||
|
||||
//gets page number/bookmark
|
||||
let title = doc.mdata("title");
|
||||
let bookmark_file_name = title.clone().unwrap() + "_bookmark";
|
||||
let next_page = title.clone().unwrap() + "_next";
|
||||
|
||||
//if bookmark for file exists, continue to open. If not, create the file and try again.
|
||||
if Path::exists(bookmark_file_name.as_ref()){
|
||||
|
||||
let next_page_var = fs::read_to_string(next_page.clone()).expect("no file found!");
|
||||
|
||||
let mut page_num: usize = next_page_var
|
||||
.trim()
|
||||
.parse()
|
||||
.expect("not a number");// converts from string to usize
|
||||
|
||||
|
||||
|
||||
page_num = page_num - 1;
|
||||
doc.set_current_page(page_num);
|
||||
let content = doc.get_current_str();
|
||||
let str_content = content.unwrap();
|
||||
let text = html_module::main(str_content.0);
|
||||
let number_title = page_num;
|
||||
|
||||
|
||||
|
||||
let page_string = page_num.to_string();
|
||||
|
||||
//writes where the next page is so that Rust knows where to go
|
||||
fs::write(next_page, page_string.as_bytes()).expect("Unable to write file");
|
||||
|
||||
//refreshed screen layout
|
||||
s.add_layer(Dialog::around(TextView::new(text))
|
||||
.title(title.unwrap() + " page: " + &number_title.to_string())
|
||||
.button("last", |s| {get_last_text(s);})
|
||||
.button("quit", |s| s.quit())
|
||||
.button("bookmark", move |s| {bookmark_func(s, page_num, &bookmark_file_name);})
|
||||
.button("next", |s| {get_text(s);})
|
||||
.scrollable()
|
||||
.scroll_x(true),
|
||||
);
|
||||
}
|
||||
|
||||
else{
|
||||
fs::write(next_page, "1").expect("Unable to write file");
|
||||
get_text(s);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
fn get_init_text(s: &mut Cursive) {
|
||||
|
||||
//removes old layer, builds new one
|
||||
s.pop_layer();
|
||||
let args: Vec<String> = env::args().collect();
|
||||
let filename = &args[1];
|
||||
let doc = EpubDoc::new(filename);
|
||||
let mut doc = doc.unwrap();
|
||||
|
||||
//gets page number/bookmark
|
||||
let title = doc.mdata("title");
|
||||
let bookmark_file_name = title.clone().unwrap() + "_bookmark";
|
||||
let next_page = title.clone().unwrap() + "_next";
|
||||
|
||||
//if bookmark for file exists, continue to open. If not, create the file and try again.
|
||||
if Path::exists(bookmark_file_name.as_ref()){
|
||||
|
||||
let starting_page = fs::read_to_string(bookmark_file_name.clone()).expect("no file found!");
|
||||
|
||||
|
||||
let mut page_num: usize = starting_page
|
||||
.trim()
|
||||
.parse()
|
||||
.expect("not a number");// converts from string to usize
|
||||
@ -132,34 +254,33 @@ fn get_text(s: &mut Cursive) {
|
||||
|
||||
let usize_num = page_num as usize; //set_current_page must be usize, not int. This line converts.
|
||||
|
||||
|
||||
|
||||
|
||||
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);
|
||||
page_num = page_num + 1;
|
||||
|
||||
//let mut bookmark_write = File::open(bookmark_file_name).expect("could not write to file.");
|
||||
|
||||
|
||||
let page_string = page_num.to_string();
|
||||
//bookmark_write.write_all(page_string.as_bytes()).expect("oops, couldn't write.");
|
||||
|
||||
fs::write(bookmark_file_name, page_string.as_bytes()).expect("Unable to write file");
|
||||
|
||||
fs::write(next_page, page_string.as_bytes()).expect("Unable to write file");
|
||||
|
||||
//refreshed screen layout
|
||||
s.add_layer(Dialog::around(TextView::new(text))
|
||||
.title(title.unwrap() + " page: " + &usize_num.to_string())
|
||||
.button("last", |s| {get_text(s);})
|
||||
.button("quit", |s| s.quit())
|
||||
.button("bookmark", move |s| {bookmark_func(s, page_num, &bookmark_file_name);})
|
||||
.button("next", |s| {get_text(s);})
|
||||
.scrollable()
|
||||
.scroll_x(true),
|
||||
);
|
||||
}
|
||||
|
||||
else{
|
||||
fs::write(bookmark_file_name, "1").expect("Unable to write file");
|
||||
get_text(s);
|
||||
get_init_text(s);
|
||||
}
|
||||
|
||||
}
|
||||
@ -167,6 +288,20 @@ fn get_text(s: &mut Cursive) {
|
||||
|
||||
|
||||
|
||||
fn bookmark_func(s: &mut Cursive, page_num: usize, bookmark: &str){
|
||||
if page_num != 1{
|
||||
let mut new_page_num = page_num;
|
||||
//new_page_num = new_page_num - 1;
|
||||
let page_string = new_page_num.to_string();
|
||||
fs::write(bookmark, page_string.as_bytes()).expect("Unable to write file");
|
||||
|
||||
}
|
||||
else{
|
||||
let page_num = "1";
|
||||
fs::write(bookmark, page_num.as_bytes()).expect("Unable to write file");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user