From 88554c41dbc1a2dcfe7cb6a2c8e277d06075b0e9 Mon Sep 17 00:00:00 2001 From: James Campos Date: Mon, 4 Jan 2021 21:52:03 -0800 Subject: tweak page progress --- src/view.rs | 5 +++-- 1 file 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::(); 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), -- cgit v1.2.3