aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Herberth <github@dav1d.de>2020-05-02 01:03:28 +0200
committerGitHub <noreply@github.com>2020-05-02 02:03:28 +0300
commit17a3b852650af5b66efd862963f28f7de6a62dcf (patch)
treef9de7060e430530e8b27a8c0e6ecaed8571993a2
parent38d20d0c391c250953ce3c72a35c8d1156f06000 (diff)
downloadalacritty-17a3b852650af5b66efd862963f28f7de6a62dcf.tar.gz
alacritty-17a3b852650af5b66efd862963f28f7de6a62dcf.zip
Use numbers instead of strings for additional mouse bindings
Fixes: #2861.
-rw-r--r--CHANGELOG.md1
-rw-r--r--alacritty/src/config/bindings.rs23
2 files changed, 14 insertions, 10 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4534989b..c99e07be 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Preserve selection on non-LMB or mouse mode clicks
- Wayland client side decorations are now based on config colorscheme
- Low resolution window decoration icon on Windows
+- Mouse bindings for additional buttons need to be specified as a number not a string
### Fixed
diff --git a/alacritty/src/config/bindings.rs b/alacritty/src/config/bindings.rs
index f9febc2a..d6520441 100644
--- a/alacritty/src/config/bindings.rs
+++ b/alacritty/src/config/bindings.rs
@@ -14,7 +14,6 @@
#![allow(clippy::enum_glob_use)]
use std::fmt::{self, Debug, Display};
-use std::str::FromStr;
use glutin::event::VirtualKeyCode::*;
use glutin::event::{ModifiersState, MouseButton, VirtualKeyCode};
@@ -621,7 +620,17 @@ impl<'a> Deserialize<'a> for MouseButtonWrapper {
type Value = MouseButtonWrapper;
fn expecting(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- f.write_str("Left, Right, Middle, or a number")
+ f.write_str("Left, Right, Middle, or a number from 0 to 255")
+ }
+
+ fn visit_u64<E>(self, value: u64) -> Result<MouseButtonWrapper, E>
+ where
+ E: de::Error,
+ {
+ match value {
+ 0..=255 => Ok(MouseButtonWrapper(MouseButton::Other(value as u8))),
+ _ => Err(E::invalid_value(Unexpected::Unsigned(value), &self)),
+ }
}
fn visit_str<E>(self, value: &str) -> Result<MouseButtonWrapper, E>
@@ -632,18 +641,12 @@ impl<'a> Deserialize<'a> for MouseButtonWrapper {
"Left" => Ok(MouseButtonWrapper(MouseButton::Left)),
"Right" => Ok(MouseButtonWrapper(MouseButton::Right)),
"Middle" => Ok(MouseButtonWrapper(MouseButton::Middle)),
- _ => {
- if let Ok(index) = u8::from_str(value) {
- Ok(MouseButtonWrapper(MouseButton::Other(index)))
- } else {
- Err(E::invalid_value(Unexpected::Str(value), &self))
- }
- },
+ _ => Err(E::invalid_value(Unexpected::Str(value), &self)),
}
}
}
- deserializer.deserialize_str(MouseButtonVisitor)
+ deserializer.deserialize_any(MouseButtonVisitor)
}
}