diff options
author | James Campos <james.r.campos@gmail.com> | 2021-01-03 17:54:33 -0800 |
---|---|---|
committer | James Campos <james.r.campos@gmail.com> | 2021-01-03 17:54:33 -0800 |
commit | f20adc60a3dcc744a3adbd40ba6aa6917f06d9c7 (patch) | |
tree | 3089a3ad03b88e1f89bb85911bc89588b7bc62a8 /src/view.rs | |
parent | 197a6cb7d5c962eb82c94b5a2304de2efcab27a6 (diff) | |
download | bk-f20adc60a3dcc744a3adbd40ba6aa6917f06d9c7.tar.gz |
cargo update
Diffstat (limited to 'src/view.rs')
-rw-r--r-- | src/view.rs | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/view.rs b/src/view.rs index bdbe0cc..1bc5ca9 100644 --- a/src/view.rs +++ b/src/view.rs @@ -2,6 +2,7 @@ use crossterm::{ event::{ KeyCode::{self, *}, MouseEvent, + MouseEventKind, }, style::Attribute, }; @@ -132,10 +133,10 @@ impl View for Nav { self.cursor(bk); } fn on_mouse(&self, bk: &mut Bk, e: MouseEvent) { - match e { - MouseEvent::Down(_, _, row, _) => self.click(bk, row as usize), - MouseEvent::ScrollDown(_, _, _) => self.next(bk, 3), - MouseEvent::ScrollUp(_, _, _) => self.prev(bk, 3), + match e.kind { + MouseEventKind::Down(_) => self.click(bk, e.row as usize), + MouseEventKind::ScrollDown => self.next(bk, 3), + MouseEventKind::ScrollUp => self.prev(bk, 3), _ => (), } } @@ -183,16 +184,16 @@ impl View for Nav { pub struct Page; impl View for Page { fn on_mouse(&self, bk: &mut Bk, e: MouseEvent) { - match e { - MouseEvent::Down(_, col, row, _) => { + match e.kind { + MouseEventKind::Down(_) => { let c = bk.chap(); - let line = bk.line + row as usize; + let line = bk.line + e.row as usize; - if col < bk.pad() || line >= c.lines.len() { + if e.column < bk.pad() || line >= c.lines.len() { return; } let (start, end) = c.lines[line]; - let line_col = (col - bk.pad()) as usize; + let line_col = (e.column - bk.pad()) as usize; let mut cols = 0; let mut found = false; @@ -227,8 +228,8 @@ impl View for Page { bk.jump((chapter, line)); } } - MouseEvent::ScrollDown(_, _, _) => bk.scroll_down(3), - MouseEvent::ScrollUp(_, _, _) => bk.scroll_up(3), + MouseEventKind::ScrollDown => bk.scroll_down(3), + MouseEventKind::ScrollUp => bk.scroll_up(3), _ => (), } } |