mirror of
https://git.meli.delivery/meli/meli
synced 2024-11-10 19:10:57 +00:00
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.
This commit is contained in:
parent
9b2621145c
commit
9c3284d3fe
@ -58,6 +58,7 @@ trait ListingTrait {
|
|||||||
fn draw_list(&mut self, grid: &mut CellBuffer, area: Area, context: &mut Context);
|
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 highlight_line(&mut self, grid: &mut CellBuffer, area: Area, idx: usize, context: &Context);
|
||||||
fn filter(&mut self, _filter_term: &str, _context: &Context) {}
|
fn filter(&mut self, _filter_term: &str, _context: &Context) {}
|
||||||
|
fn set_movement(&mut self, mvm: PageMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -102,6 +103,14 @@ impl ListingTrait for ListingComponent {
|
|||||||
Conversations(ref mut l) => l.highlight_line(grid, area, idx, context),
|
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 {
|
impl ListingComponent {
|
||||||
@ -392,6 +401,22 @@ impl Component for Listing {
|
|||||||
UIEvent::Resize => {
|
UIEvent::Resize => {
|
||||||
self.dirty = true;
|
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"] => {
|
UIEvent::Input(ref k) if k == shortcuts["toggle-menu-visibility"] => {
|
||||||
self.menu_visibility = !self.menu_visibility;
|
self.menu_visibility = !self.menu_visibility;
|
||||||
self.set_dirty();
|
self.set_dirty();
|
||||||
|
@ -442,6 +442,11 @@ impl ListingTrait for CompactListing {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_movement(&mut self, mvm: PageMovement) {
|
||||||
|
self.movement = Some(mvm);
|
||||||
|
self.set_dirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for CompactListing {
|
impl fmt::Display for CompactListing {
|
||||||
@ -1111,22 +1116,6 @@ impl Component for CompactListing {
|
|||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(ref key) if *key == shortcuts["prev_page"] => {
|
|
||||||
self.movement = Some(PageMovement::PageUp);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == shortcuts["next_page"] => {
|
|
||||||
self.movement = Some(PageMovement::PageDown);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == Key::Home => {
|
|
||||||
self.movement = Some(PageMovement::Home);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == Key::End => {
|
|
||||||
self.movement = Some(PageMovement::End);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == shortcuts["set_seen"] => {
|
UIEvent::Input(ref key) if *key == shortcuts["set_seen"] => {
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
self.perform_action(context, thread_hash, &ListingAction::SetSeen);
|
self.perform_action(context, thread_hash, &ListingAction::SetSeen);
|
||||||
|
@ -483,6 +483,11 @@ impl ListingTrait for ConversationsListing {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_movement(&mut self, mvm: PageMovement) {
|
||||||
|
self.movement = Some(mvm);
|
||||||
|
self.set_dirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for ConversationsListing {
|
impl fmt::Display for ConversationsListing {
|
||||||
@ -1193,22 +1198,6 @@ impl Component for ConversationsListing {
|
|||||||
self.dirty = true;
|
self.dirty = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
UIEvent::Input(ref key) if *key == shortcuts["prev_page"] => {
|
|
||||||
self.movement = Some(PageMovement::PageUp);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == shortcuts["next_page"] => {
|
|
||||||
self.movement = Some(PageMovement::PageDown);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == Key::Home => {
|
|
||||||
self.movement = Some(PageMovement::Home);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == Key::End => {
|
|
||||||
self.movement = Some(PageMovement::End);
|
|
||||||
self.set_dirty();
|
|
||||||
}
|
|
||||||
UIEvent::Input(ref key) if *key == shortcuts["set_seen"] => {
|
UIEvent::Input(ref key) if *key == shortcuts["set_seen"] => {
|
||||||
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
let thread_hash = self.get_thread_under_cursor(self.cursor_pos.2, context);
|
||||||
self.perform_action(context, thread_hash, &ListingAction::SetSeen);
|
self.perform_action(context, thread_hash, &ListingAction::SetSeen);
|
||||||
|
@ -213,6 +213,11 @@ impl ListingTrait for PlainListing {
|
|||||||
);
|
);
|
||||||
context.dirty_areas.push_back(area);
|
context.dirty_areas.push_back(area);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_movement(&mut self, mvm: PageMovement) {
|
||||||
|
self.movement = Some(mvm);
|
||||||
|
self.set_dirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for PlainListing {
|
impl Default for PlainListing {
|
||||||
|
@ -197,6 +197,11 @@ impl ListingTrait for ThreadListing {
|
|||||||
change_colors(grid, area, fg_color, bg_color);
|
change_colors(grid, area, fg_color, bg_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn set_movement(&mut self, mvm: PageMovement) {
|
||||||
|
self.movement = Some(mvm);
|
||||||
|
self.set_dirty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ThreadListing {
|
impl Default for ThreadListing {
|
||||||
|
Loading…
Reference in New Issue
Block a user