From 2670e6ffd41ab595d6972306e525effbb3ba1bd1 Mon Sep 17 00:00:00 2001 From: Daniel Jones Date: Fri, 3 Nov 2023 11:27:38 -0500 Subject: [PATCH] page turning figured out. Must make get_text recursive so that you can call it again once you are done reading. --- .idea/workspace.xml | 15 ++++++++++++--- src/main.rs | 16 ++++++++++++++-- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/.idea/workspace.xml b/.idea/workspace.xml index b116a31..c558439 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -15,7 +15,7 @@ - + @@ -190,7 +190,15 @@ @@ -236,7 +244,8 @@ - diff --git a/src/main.rs b/src/main.rs index 118a4e0..a7ec119 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,9 +83,21 @@ fn get_text(s: &mut Cursive, mut page_num: &i32, direction: &str) { s.pop_layer(); let args: Vec = env::args().collect(); let filename = &args[1]; - let doc = EpubDoc::new(&epub_file); + let doc = EpubDoc::new(filename); + let mut doc = doc.unwrap(); + let mut usize_num = *page_num as usize; + usize_num = usize_num + 1; + let title = doc.mdata("title"); - s.add_layer(Dialog::text("D has been pressed! Congratulations! You figured this shit out!")); + 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()) + .scrollable() + .scroll_x(true), + ); }