From 4a9c1a0bf6addaa1992f4ca9d1d482de50a79355 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sat, 29 Aug 2020 22:02:23 -0700 Subject: try to start nav with current chapter centered --- src/view.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/view.rs b/src/view.rs index 092631d..bc9bd77 100644 --- a/src/view.rs +++ b/src/view.rs @@ -107,6 +107,11 @@ PageDown Right Space f l Page Down pub struct Nav; impl Nav { + fn start(&self, bk: &mut Bk) { + bk.nav_top = bk.chapter.saturating_sub(bk.rows / 2); + bk.mark('\''); + bk.view = Some(&Self); + } fn scroll_up(&self, bk: &mut Bk) { if bk.chapter > 0 { if bk.chapter == bk.nav_top { @@ -257,11 +262,7 @@ impl View for Page { fn on_key(&self, bk: &mut Bk, kc: KeyCode) { match kc { Esc | Char('q') => bk.view = None, - Tab => { - bk.nav_top = bk.chapter.saturating_sub(bk.rows - 1); - bk.mark('\''); - bk.view = Some(&Nav); - } + Tab => Nav.start(bk), F(_) => bk.view = Some(&Help), Char('m') => bk.view = Some(&Mark), Char('\'') => bk.view = Some(&Jump), -- cgit v1.2.3