summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Thiel <sebastian.thiel@icloud.com>2021-02-15 14:27:43 +0800
committerSebastian Thiel <sebastian.thiel@icloud.com>2021-02-15 14:30:45 +0800
commit8b606ac464ec5fa3979ab73fef4d29733d389760 (patch)
treecd8ae85097e122d9dd6c01aa1ca3ab8cf7eb35c4
parent8cc2f44b4cd89cc046f1748f664d112d0278aa6d (diff)
Add bindings 'H' and 'G' to go to the top/bottom of any pane
Fixes #78
-rw-r--r--CHANGELOG.md5
-rw-r--r--src/interactive/app/eventloop.rs8
-rw-r--r--src/interactive/app/handlers.rs6
-rw-r--r--src/interactive/widgets/help.rs6
-rw-r--r--src/interactive/widgets/mark.rs4
5 files changed, 25 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f191765..9032aed 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+#### v2.11.0
+
+* Add binding capital 'H' to go to the top of any pane/list
+* Add binding capital 'G' to go to the bottom of any pane/list
+
#### v2.10.10 - Fix --version flag
It looks like the latest BETAs of clap removed setting the version implicitly.
diff --git a/src/interactive/app/eventloop.rs b/src/interactive/app/eventloop.rs
index fbea68c..ed7c2ac 100644
--- a/src/interactive/app/eventloop.rs
+++ b/src/interactive/app/eventloop.rs
@@ -110,7 +110,11 @@ impl AppState {
self.dispatch_to_mark_pane(key, window, traversal, *display, terminal)
}
FocussedPane::Help => {
- window.help_pane.as_mut().expect("help pane").key(key);
+ window
+ .help_pane
+ .as_mut()
+ .expect("help pane")
+ .process_events(key);
}
FocussedPane::Main => match key {
Char('O') => self.open_that(traversal),
@@ -138,6 +142,8 @@ impl AppState {
Char('o') | Char('l') | Char('\n') | Right => {
self.enter_node_with_traversal(traversal)
}
+ Char('H') => self.change_entry_selection(CursorDirection::ToTop),
+ Char('G') => self.change_entry_selection(CursorDirection::ToBottom),
Ctrl('u') | PageUp => self.change_entry_selection(CursorDirection::PageUp),
Char('k') | Up => self.change_entry_selection(CursorDirection::Up),
Char('j') | Down => self.change_entry_selection(CursorDirection::Down),
diff --git a/src/interactive/app/handlers.rs b/src/interactive/app/handlers.rs
index e940997..2360aae 100644
--- a/src/interactive/app/handlers.rs
+++ b/src/interactive/app/handlers.rs
@@ -29,12 +29,16 @@ pub enum CursorDirection {
Down,
Up,
PageUp,
+ ToTop,
+ ToBottom,
}
impl CursorDirection {
pub fn move_cursor(&self, n: usize) -> usize {
use CursorDirection::*;
match self {
+ ToTop => 0,
+ ToBottom => usize::MAX,
Down => n.saturating_add(1),
Up => n.saturating_sub(1),
PageDown => n.saturating_add(10),
@@ -202,7 +206,7 @@ impl AppState {
) where
B: Backend,
{
- let res = window.mark_pane.take().and_then(|p| p.key(key));
+ let res = window.mark_pane.take().and_then(|p| p.process_events(key));
window.mark_pane = match res {
Some((pane, mode)) => match mode {
Some(MarkMode::Delete) => {
diff --git a/src/interactive/widgets/help.rs b/src/interactive/widgets/help.rs
index de0dd1b..c7574cc 100644
--- a/src/interactive/widgets/help.rs
+++ b/src/interactive/widgets/help.rs
@@ -33,8 +33,10 @@ fn margin(r: Rect, margin: u16) -> Rect {
}
impl HelpPane {
- pub fn key(&mut self, key: Key) {
+ pub fn process_events(&mut self, key: Key) {
match key {
+ Char('H') => self.scroll_help(CursorDirection::ToTop),
+ Char('G') => self.scroll_help(CursorDirection::ToBottom),
Ctrl('u') | PageUp => self.scroll_help(CursorDirection::PageUp),
Char('k') | Up => self.scroll_help(CursorDirection::Up),
Char('j') | Down => self.scroll_help(CursorDirection::Down),
@@ -120,6 +122,8 @@ impl HelpPane {
hotkey("<Page Down>", "^", None);
hotkey("Ctrl + u", "move up 10 entries at once", None);
hotkey("<Page Up>", "^", None);
+ hotkey("H", "Move to the top of the entries list", None);
+ hotkey("G", "Move to the bottomw of the entries list", None);
spacer();
}
title("Keys for display");
diff --git a/src/interactive/widgets/mark.rs b/src/interactive/widgets/mark.rs
index cdae961..b165415 100644
--- a/src/interactive/widgets/mark.rs
+++ b/src/interactive/widgets/mark.rs
@@ -102,13 +102,15 @@ impl MarkPane {
pub fn marked(&self) -> &EntryMarkMap {
&self.marked
}
- pub fn key(mut self, key: Key) -> Option<(Self, Option<MarkMode>)> {
+ pub fn process_events(mut self, key: Key) -> Option<(Self, Option<MarkMode>)> {
let action = None;
match key {
Ctrl('r') => return self.prepare_deletion(),
Char('x') | Char('d') | Char(' ') => {
return self.remove_selected().map(|s| (s, action))
}
+ Char('H') => self.change_selection(CursorDirection::ToTop),
+ Char('G') => self.change_selection(CursorDirection::ToBottom),
Ctrl('u') | PageUp => self.change_selection(CursorDirection::PageUp),
Char('k') | Up => self.change_selection(CursorDirection::Up),
Char('j') | Down => self.change_selection(CursorDirection::Down),