aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2021-01-04 21:52:03 -0800
committerJames Campos <james.r.campos@gmail.com>2021-01-04 21:52:03 -0800
commit88554c41dbc1a2dcfe7cb6a2c8e277d06075b0e9 (patch)
tree10bc5b0c9fec85aa4f7715eb1e82fa4739774f8f
parentb6dda9fa8e1c159412c177fb3cc0a55652091d35 (diff)
downloadbk-88554c41dbc1a2dcfe7cb6a2c8e277d06075b0e9.tar.gz
tweak page progress
-rw-r--r--src/view.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/view.rs b/src/view.rs
index 50af1c6..1fdb449 100644
--- a/src/view.rs
+++ b/src/view.rs
@@ -58,8 +58,9 @@ impl View for Metadata {
let total = lines.iter().sum::<usize>();
let progress = current as f32 / total as f32 * 100.0;
- let pages = lines[bk.chapter] / bk.rows;
- let page = bk.line / bk.rows;
+ let pages = (lines[bk.chapter] as f32 / bk.rows as f32).ceil() as usize;
+ // if the last line is visible we're on the last page. first page is the short one
+ let page = pages - (lines[bk.chapter] - 1 - bk.line) / bk.rows;
let mut vec = vec![
format!("chapter: {}/{}", page, pages),