From cd233ffb54f2eb4c05cb4d84bc33ce528846534a Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 3 Nov 2020 12:46:35 -0700 Subject: [PATCH 1/2] Add g and G support for top and bottom --- src/app.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index b4ddd9b..3f5729b 100644 --- a/src/app.rs +++ b/src/app.rs @@ -4,7 +4,7 @@ use crate::context::Context; use crate::help::Help; use crate::table::{Row, Table, TableState}; use crate::task_report::TaskReportTable; -use crate::util::Events; +use crate::util::{Events, Event}; use crate::util::Key; use std::cmp::Ordering; @@ -679,6 +679,20 @@ impl TTApp { .output(); } + pub fn task_report_top(&mut self) { + if self.tasks.lock().unwrap().is_empty() { + return; + } + self.task_table_state.select(Some(0)); + } + + pub fn task_report_bottom(&mut self) { + if self.tasks.lock().unwrap().is_empty() { + return; + } + self.task_table_state.select(Some(self.tasks.lock().unwrap().len() - 1)); + } + pub fn task_report_next(&mut self) { if self.tasks.lock().unwrap().is_empty() { return; @@ -1247,6 +1261,8 @@ impl TTApp { AppMode::TaskReport => match input { Key::Ctrl('c') | Key::Char('q') => self.should_quit = true, Key::Char('r') => self.update()?, + Key::Char('g') => self.task_report_top(), + Key::Char('G') => self.task_report_bottom(), Key::Down | Key::Char('j') => self.task_report_next(), Key::Up | Key::Char('k') => self.task_report_previous(), Key::PageDown | Key::Char('J') => self.task_report_next_page(), From b755c23c1af5f1591618c975455645a277cb5f04 Mon Sep 17 00:00:00 2001 From: Dheepak Krishnamurthy Date: Tue, 3 Nov 2020 12:47:10 -0700 Subject: [PATCH 2/2] Add Home and End support for top and bottom --- src/app.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.rs b/src/app.rs index 3f5729b..8796596 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1261,8 +1261,8 @@ impl TTApp { AppMode::TaskReport => match input { Key::Ctrl('c') | Key::Char('q') => self.should_quit = true, Key::Char('r') => self.update()?, - Key::Char('g') => self.task_report_top(), - Key::Char('G') => self.task_report_bottom(), + Key::Home | Key::Char('g') => self.task_report_top(), + Key::End | Key::Char('G') => self.task_report_bottom(), Key::Down | Key::Char('j') => self.task_report_next(), Key::Up | Key::Char('k') => self.task_report_previous(), Key::PageDown | Key::Char('J') => self.task_report_next_page(),