diff options
author | James Campos <james.r.campos@gmail.com> | 2020-11-25 14:19:05 -0800 |
---|---|---|
committer | James Campos <james.r.campos@gmail.com> | 2020-11-25 14:19:05 -0800 |
commit | b6cfca110cc90a5da88e7409aa60cdfa1fefad72 (patch) | |
tree | 5cf567161a66d66940f73a5d038261964955e4a2 /src/view.rs | |
parent | 2a9bd053196deb7710729bc3541e7d5feb9e4856 (diff) | |
download | bk-b6cfca110cc90a5da88e7409aa60cdfa1fefad72.tar.gz |
on_resize
Diffstat (limited to 'src/view.rs')
-rw-r--r-- | src/view.rs | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/view.rs b/src/view.rs index cdb2ceb..d92ad58 100644 --- a/src/view.rs +++ b/src/view.rs @@ -14,6 +14,7 @@ pub trait View { fn render(&self, bk: &Bk) -> Vec<String>; fn on_key(&self, bk: &mut Bk, kc: KeyCode); fn on_mouse(&self, _: &mut Bk, _: MouseEvent) {} + fn on_resize(&self, _: &mut Bk) {} } // TODO render something useful? @@ -127,6 +128,9 @@ impl Nav { } } impl View for Nav { + fn on_resize(&self, bk: &mut Bk) { + self.cursor(bk); + } fn on_mouse(&self, bk: &mut Bk, e: MouseEvent) { match e { MouseEvent::Down(_, _, row, _) => self.click(bk, row as usize), @@ -273,6 +277,10 @@ impl View for Page { _ => (), } } + fn on_resize(&self, bk: &mut Bk) { + // lazy + bk.line = min(bk.line, bk.chap().lines.len() - 1); + } fn render(&self, bk: &Bk) -> Vec<String> { let c = bk.chap(); let line_end = min(bk.line + bk.rows, c.lines.len()); |