aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Campos <james.r.campos@gmail.com>2020-08-29 22:02:23 -0700
committerJames Campos <james.r.campos@gmail.com>2020-08-29 22:02:23 -0700
commit4a9c1a0bf6addaa1992f4ca9d1d482de50a79355 (patch)
treec65c5f7c4a6be5b38ce5f2f213774f2f952c4974 /src
parent8e094724ca23c2edd2f617750c3e000e5f9740d7 (diff)
downloadbk-4a9c1a0bf6addaa1992f4ca9d1d482de50a79355.tar.gz
try to start nav with current chapter centered
Diffstat (limited to 'src')
-rw-r--r--src/view.rs11
1 files changed, 6 insertions, 5 deletions
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),