diff options
author | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-10-12 17:41:06 +0300 |
---|---|---|
committer | Manos Pitsidianakis <el13635@mail.ntua.gr> | 2019-10-15 23:47:37 +0300 |
commit | 9c3284d3fef9c5fdba5dd9655b43a083ae08c835 (patch) | |
tree | 08da832b83083d866367b7c840b1fce6b7ab6653 /ui/src/components/mail/listing.rs | |
parent | 9b2621145cd5168740c128f83e8bf4af62178ce9 (diff) |
ui/listings: add set_movement method to ListingComponent
Page movements is an enum that describes the movements of the keyboard
keys "Home, End, PageUp, PageDown". Some mail listing Components
interpret these keys as changes to their cursors.
Diffstat (limited to 'ui/src/components/mail/listing.rs')
-rw-r--r-- | ui/src/components/mail/listing.rs | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ui/src/components/mail/listing.rs b/ui/src/components/mail/listing.rs index ec021d24..3b815971 100644 --- a/ui/src/components/mail/listing.rs +++ b/ui/src/components/mail/listing.rs @@ -58,6 +58,7 @@ trait ListingTrait { fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context); fn highlight_line(&mut self, grid: &mut CellBuffer, area: Area, idx: usize, context: &Context); fn filter(&mut self, _filter_term: &str, _context: &Context) {} + fn set_movement(&mut self, mvm: PageMovement); } #[derive(Debug)] @@ -102,6 +103,14 @@ impl ListingTrait for ListingComponent { Conversations(ref mut l) => l.highlight_line(grid, area, idx, context), } } + fn set_movement(&mut self, mvm: PageMovement) { + match self { + Compact(ref mut l) => l.set_movement(mvm), + Plain(ref mut l) => l.set_movement(mvm), + Threaded(ref mut l) => l.set_movement(mvm), + Conversations(ref mut l) => l.set_movement(mvm), + } + } } impl ListingComponent { @@ -392,6 +401,22 @@ impl Component for Listing { UIEvent::Resize => { self.dirty = true; } + UIEvent::Input(ref key) if *key == shortcuts["prev_page"] => { + self.component.set_movement(PageMovement::PageUp); + return true; + } + UIEvent::Input(ref key) if *key == shortcuts["next_page"] => { + self.component.set_movement(PageMovement::PageDown); + return true; + } + UIEvent::Input(ref key) if *key == Key::Home => { + self.component.set_movement(PageMovement::Home); + return true; + } + UIEvent::Input(ref key) if *key == Key::End => { + self.component.set_movement(PageMovement::End); + return true; + } UIEvent::Input(ref k) if k == shortcuts["toggle-menu-visibility"] => { self.menu_visibility = !self.menu_visibility; self.set_dirty(); |