aboutsummaryrefslogtreecommitdiffstats
path: root/src/common
diff options
context:
space:
mode:
authorBrooks Rady <b.j.rady@gmail.com>2021-04-22 00:25:43 +0100
committerGitHub <noreply@github.com>2021-04-22 00:25:43 +0100
commit19fc0496a34565049cf1085ebf7071b7a6d3ef3d (patch)
treef1ec6c15136949b9b5521275289a1bd7ab9ab194 /src/common
parentdocs(changelog): update status bar change (diff)
parentadd PGUP/PGDN to help info (diff)
downloadsl0ppij-19fc0496a34565049cf1085ebf7071b7a6d3ef3d.tar.gz
sl0ppij-19fc0496a34565049cf1085ebf7071b7a6d3ef3d.tar.xz
sl0ppij-19fc0496a34565049cf1085ebf7071b7a6d3ef3d.zip
feat(actions): allow scrolling by full pages
PR #298
Diffstat (limited to 'src/common')
-rw-r--r--src/common/errors.rs4
-rw-r--r--src/common/input/actions.rs4
-rw-r--r--src/common/input/handler.rs11
-rw-r--r--src/common/input/keybinds.rs5
-rw-r--r--src/common/mod.rs12
-rw-r--r--src/common/screen.rs2
6 files changed, 38 insertions, 0 deletions
diff --git a/src/common/errors.rs b/src/common/errors.rs
index d0b748ab..dd675738 100644
--- a/src/common/errors.rs
+++ b/src/common/errors.rs
@@ -196,6 +196,8 @@ pub enum ScreenContext {
Quit,
ScrollUp,
ScrollDown,
+ PageScrollUp,
+ PageScrollDown,
ClearScroll,
CloseFocusedPane,
ToggleActiveTerminalFullscreen,
@@ -238,6 +240,8 @@ impl From<&ScreenInstruction> for ScreenContext {
ScreenInstruction::Quit => ScreenContext::Quit,
ScreenInstruction::ScrollUp => ScreenContext::ScrollUp,
ScreenInstruction::ScrollDown => ScreenContext::ScrollDown,
+ ScreenInstruction::PageScrollUp => ScreenContext::PageScrollUp,
+ ScreenInstruction::PageScrollDown => ScreenContext::PageScrollDown,
ScreenInstruction::ClearScroll => ScreenContext::ClearScroll,
ScreenInstruction::CloseFocusedPane => ScreenContext::CloseFocusedPane,
ScreenInstruction::ToggleActiveTerminalFullscreen => {
diff --git a/src/common/input/actions.rs b/src/common/input/actions.rs
index 47a5f763..3bcadf15 100644
--- a/src/common/input/actions.rs
+++ b/src/common/input/actions.rs
@@ -33,6 +33,10 @@ pub enum Action {
ScrollUp,
/// Scroll down in focus pane.
ScrollDown,
+ /// Scroll up one page in focus pane.
+ PageScrollUp,
+ /// Scroll down one page in focus pane.
+ PageScrollDown,
/// Toggle between fullscreen focus pane and normal layout.
ToggleFocusFullscreen,
/// Open a new pane in the specified direction (relative to focus).
diff --git a/src/common/input/handler.rs b/src/common/input/handler.rs
index 0afcab10..8abb2a0f 100644
--- a/src/common/input/handler.rs
+++ b/src/common/input/handler.rs
@@ -184,6 +184,16 @@ impl InputHandler {
.send(ScreenInstruction::ScrollDown)
.unwrap();
}
+ Action::PageScrollUp => {
+ self.send_screen_instructions
+ .send(ScreenInstruction::PageScrollUp)
+ .unwrap();
+ }
+ Action::PageScrollDown => {
+ self.send_screen_instructions
+ .send(ScreenInstruction::PageScrollDown)
+ .unwrap();
+ }
Action::ToggleFocusFullscreen => {
self.send_screen_instructions
.send(ScreenInstruction::ToggleActiveTerminalFullscreen)
@@ -293,6 +303,7 @@ pub fn get_mode_info(mode: InputMode) -> ModeInfo {
}
InputMode::Scroll => {
keybinds.push(("↓↑".to_string(), "Scroll".to_string()));
+ keybinds.push(("PGUP/PGDN".to_string(), "Scroll Page".to_string()));
}
InputMode::RenameTab => {
keybinds.push(("Enter".to_string(), "when done".to_string()));
diff --git a/src/common/input/keybinds.rs b/src/common/input/keybinds.rs
index 6239475e..8e04c44a 100644
--- a/src/common/input/keybinds.rs
+++ b/src/common/input/keybinds.rs
@@ -340,6 +340,11 @@ impl Keybinds {
defaults.insert(Key::Char('j'), vec![Action::ScrollDown]);
defaults.insert(Key::Char('k'), vec![Action::ScrollUp]);
+ defaults.insert(Key::Ctrl('f'), vec![Action::PageScrollDown]);
+ defaults.insert(Key::Ctrl('b'), vec![Action::PageScrollUp]);
+ defaults.insert(Key::PageDown, vec![Action::PageScrollDown]);
+ defaults.insert(Key::PageUp, vec![Action::PageScrollUp]);
+
defaults.insert(Key::Down, vec![Action::ScrollDown]);
defaults.insert(Key::Up, vec![Action::ScrollUp]);
diff --git a/src/common/mod.rs b/src/common/mod.rs
index 1a26e108..79e48780 100644
--- a/src/common/mod.rs
+++ b/src/common/mod.rs
@@ -369,6 +369,18 @@ pub fn start(mut os_input: Box<dyn OsApi>, opts: CliArgs) {
.unwrap()
.scroll_active_terminal_down();
}
+ ScreenInstruction::PageScrollUp => {
+ screen
+ .get_active_tab_mut()
+ .unwrap()
+ .scroll_active_terminal_up_page();
+ }
+ ScreenInstruction::PageScrollDown => {
+ screen
+ .get_active_tab_mut()
+ .unwrap()
+ .scroll_active_terminal_down_page();
+ }
ScreenInstruction::ClearScroll => {
screen
.get_active_tab_mut()
diff --git a/src/common/screen.rs b/src/common/screen.rs
index 01ac04fc..a2f41574 100644
--- a/src/common/screen.rs
+++ b/src/common/screen.rs
@@ -38,6 +38,8 @@ pub enum ScreenInstruction {
Quit,
ScrollUp,
ScrollDown,
+ PageScrollUp,
+ PageScrollDown,
ClearScroll,
CloseFocusedPane,
ToggleActiveTerminalFullscreen,