aboutsummaryrefslogtreecommitdiff
path: root/alacritty/src/config/bindings.rs
diff options
context:
space:
mode:
authorJason Heard <jasonh@pandell.com>2021-07-29 09:40:51 -0600
committerGitHub <noreply@github.com>2021-07-29 15:40:51 +0000
commit3c309a0953566fe6f726b84eb117fd9cfa42df3d (patch)
treed6f4c6200bc4f9a6abb192adeee5bb15b4603815 /alacritty/src/config/bindings.rs
parent96a098c358870e8be41921f19ed72810651106ae (diff)
downloadr-alacritty-3c309a0953566fe6f726b84eb117fd9cfa42df3d.tar.gz
r-alacritty-3c309a0953566fe6f726b84eb117fd9cfa42df3d.tar.bz2
r-alacritty-3c309a0953566fe6f726b84eb117fd9cfa42df3d.zip
Add ExpandSelection mouse binding action
Fixes #4132.
Diffstat (limited to 'alacritty/src/config/bindings.rs')
-rw-r--r--alacritty/src/config/bindings.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index 57237ad3..a4271430 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -109,6 +109,10 @@ pub enum Action {
#[config(skip)]
Search(SearchAction),
+ /// Perform mouse binding exclusive action.
+ #[config(skip)]
+ Mouse(MouseAction),
+
/// Paste contents of system clipboard.
Paste,
@@ -227,12 +231,19 @@ impl From<SearchAction> for Action {
}
}
+impl From<MouseAction> for Action {
+ fn from(action: MouseAction) -> Self {
+ Self::Mouse(action)
+ }
+}
+
/// Display trait used for error logging.
impl Display for Action {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Action::ViMotion(motion) => motion.fmt(f),
Action::Vi(action) => action.fmt(f),
+ Action::Mouse(action) => action.fmt(f),
_ => write!(f, "{:?}", self),
}
}
@@ -283,6 +294,13 @@ pub enum SearchAction {
SearchHistoryNext,
}
+/// Mouse binding specific actions.
+#[derive(ConfigDeserialize, Debug, Copy, Clone, PartialEq, Eq)]
+pub enum MouseAction {
+ /// Expand the selection to the current mouse cursor position.
+ ExpandSelection,
+}
+
macro_rules! bindings {
(
KeyBinding;
@@ -343,6 +361,7 @@ macro_rules! bindings {
pub fn default_mouse_bindings() -> Vec<MouseBinding> {
bindings!(
MouseBinding;
+ MouseButton::Right; MouseAction::ExpandSelection;
MouseButton::Middle, ~BindingMode::VI; Action::PasteSelection;
)
}
@@ -1027,6 +1046,9 @@ impl<'a> Deserialize<'a> for RawBinding {
SearchAction::deserialize(value.clone())
{
Some(search_action.into())
+ } else if let Ok(mouse_action) = MouseAction::deserialize(value.clone())
+ {
+ Some(mouse_action.into())
} else {
match Action::deserialize(value.clone()).map_err(V::Error::custom) {
Ok(action) => Some(action),
@@ -1102,6 +1124,15 @@ impl<'a> Deserialize<'a> for RawBinding {
}
action
},
+ (Some(action @ Action::Mouse(_)), None, None) => {
+ if mouse.is_none() {
+ return Err(V::Error::custom(format!(
+ "action `{}` is only available for mouse bindings",
+ action,
+ )));
+ }
+ action
+ },
(Some(action), None, None) => action,
(None, Some(chars), None) => Action::Esc(chars),
(None, None, Some(cmd)) => Action::Command(cmd),