diff options
author | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-06 16:57:05 +0530 |
---|---|---|
committer | Sebastian Thiel <sthiel@thoughtworks.com> | 2019-06-06 16:57:05 +0530 |
commit | 29c0cf3c5a584764e060dd9f34592edbc8098562 (patch) | |
tree | 4c267272d651da56c69eb5804758f57a50771cae /src/interactive/widgets/mark.rs | |
parent | 04f5324b17efe4c7b62a0afc7d2b34304a9a4407 (diff) |
A step towards more self-contained components
Diffstat (limited to 'src/interactive/widgets/mark.rs')
-rw-r--r-- | src/interactive/widgets/mark.rs | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs index d04adb8..ed31ece 100644 --- a/src/interactive/widgets/mark.rs +++ b/src/interactive/widgets/mark.rs @@ -1,7 +1,8 @@ -use crate::interactive::{widgets::COLOR_MARKED_LIGHT, EntryMarkMap}; +use crate::interactive::{widgets::COLOR_MARKED_LIGHT, CursorDirection, EntryMarkMap, Handle}; use dua::traverse::TreeIndex; use itertools::Itertools; use std::borrow::Borrow; +use termion::{event::Key, event::Key::*}; use tui::{ buffer::Buffer, layout::Rect, style::Style, widgets::Block, widgets::Borders, widgets::Text, }; @@ -18,7 +19,20 @@ pub struct MarkPaneProps<'a> { pub marked: &'a EntryMarkMap, } +impl Handle for MarkPane { + fn key(&mut self, key: Key) { + match key { + Ctrl('u') | PageUp => self.change_selection(CursorDirection::PageUp), + Char('k') | Up => self.change_selection(CursorDirection::Up), + Char('j') | Down => self.change_selection(CursorDirection::Down), + Ctrl('d') | PageDown => self.change_selection(CursorDirection::PageDown), + _ => {} + }; + } +} + impl MarkPane { + fn change_selection(&mut self, _direction: CursorDirection) {} pub fn render<'a>( &mut self, props: impl Borrow<MarkPaneProps<'a>>, |