aboutsummaryrefslogtreecommitdiff
path: root/src/input
diff options
context:
space:
mode:
Diffstat (limited to 'src/input')
-rw-r--r--src/input/keybind_help.rs1
-rw-r--r--src/input/keybindings.rs36
2 files changed, 37 insertions, 0 deletions
diff --git a/src/input/keybind_help.rs b/src/input/keybind_help.rs
index e9462b9d..2f89b861 100644
--- a/src/input/keybind_help.rs
+++ b/src/input/keybind_help.rs
@@ -160,6 +160,7 @@ pub(crate) fn keybind_help_groups(
entry(binding_label(&keybinds.close_pane), "close pane"),
entry(binding_label(&keybinds.rename_pane), "rename pane"),
entry(binding_label(&keybinds.edit_scrollback), "edit scrollback"),
+ entry(binding_label(&keybinds.clear_pane), "clear pane"),
entry(binding_label(&keybinds.copy_mode), "copy mode"),
entry(binding_label(&keybinds.zoom), "zoom pane"),
entry(binding_label(&keybinds.resize_mode), "resize mode"),
diff --git a/src/input/keybindings.rs b/src/input/keybindings.rs
index d56de80c..9ffce2ee 100644
--- a/src/input/keybindings.rs
+++ b/src/input/keybindings.rs
@@ -52,6 +52,7 @@ pub(crate) enum KeybindAction {
SplitHorizontal,
ClosePane,
EditScrollback,
+ ClearPane,
CopyMode,
Zoom,
EnterResizeMode,
@@ -120,6 +121,7 @@ pub(crate) fn resolve_non_indexed_action(
(&keybinds.close_tab, KeybindAction::CloseTab),
(&keybinds.rename_pane, KeybindAction::RenamePane),
(&keybinds.edit_scrollback, KeybindAction::EditScrollback),
+ (&keybinds.clear_pane, KeybindAction::ClearPane),
(&keybinds.copy_mode, KeybindAction::CopyMode),
(&keybinds.focus_pane_left, KeybindAction::FocusPaneLeft),
(&keybinds.focus_pane_down, KeybindAction::FocusPaneDown),
@@ -259,6 +261,40 @@ mod tests {
use super::*;
#[test]
+ fn clear_pane_is_unbound_by_default_and_configurable() {
+ assert!(crate::config::Config::default()
+ .keybinds()
+ .clear_pane
+ .bindings
+ .is_empty());
+ let config: crate::config::Config =
+ toml::from_str("[keys]\nclear_pane = [\"super+k\", \"prefix+ctrl+k\"]").unwrap();
+ assert!(config.collect_diagnostics().is_empty());
+ let keybinds = config.keybinds();
+ assert!(matches!(
+ resolve_direct_binding(
+ &keybinds,
+ &TerminalKey::new(KeyCode::Char('k'), KeyModifiers::SUPER)
+ ),
+ Some(KeybindMatch::Action(KeybindAction::ClearPane))
+ ));
+ assert!(matches!(
+ resolve_prefix_binding(
+ &keybinds,
+ &TerminalKey::new(KeyCode::Char('k'), KeyModifiers::CONTROL)
+ ),
+ Some(KeybindMatch::Action(KeybindAction::ClearPane))
+ ));
+ assert!(matches!(
+ resolve_prefix_binding(
+ &keybinds,
+ &TerminalKey::new(KeyCode::Char('k'), KeyModifiers::SHIFT)
+ ),
+ Some(KeybindMatch::Action(KeybindAction::SwapPaneUp))
+ ));
+ }
+
+ #[test]
fn one_shared_resolver_handles_direct_prefix_and_indexed_bindings() {
let keybinds = Keybinds {
next_tab: crate::config::ActionKeybinds::direct("ctrl+n"),