1
0
Fork 0
mirror of https://github.com/alacritty/alacritty.git synced 2024-11-25 14:05:41 -05:00

Prefer exact matches for bindings in mouse mode

Only consider bindings without Shift if there are no actions defined for the
actual mouse event.

Closes #7292.
This commit is contained in:
Pavel Roskin 2023-10-24 17:04:32 -07:00 committed by GitHub
parent d66db480cf
commit 500b696ca8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 10 deletions

View file

@ -42,6 +42,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Apply `colors.transparent_background_colors` for selections, hints, and search matches - Apply `colors.transparent_background_colors` for selections, hints, and search matches
- Underline full hint during keyboard selection - Underline full hint during keyboard selection
- Synchronized updates now use `CSI 2026` instead of legacy `DCS` variant - Synchronized updates now use `CSI 2026` instead of legacy `DCS` variant
- In mouse mode with `Shift` pressed, mouse bindings without `Shift` are only triggered
if no exact binding (i.e. one with `Shift`) is found.
### Fixed ### Fixed

View file

@ -1003,17 +1003,24 @@ impl<T: EventListener, A: ActionContext<T>> Processor<T, A> {
let mode = BindingMode::new(self.ctx.terminal().mode(), self.ctx.search_active()); let mode = BindingMode::new(self.ctx.terminal().mode(), self.ctx.search_active());
let mouse_mode = self.ctx.mouse_mode(); let mouse_mode = self.ctx.mouse_mode();
let mods = self.ctx.modifiers().state(); let mods = self.ctx.modifiers().state();
let mouse_bindings = self.ctx.config().mouse_bindings().to_owned();
for i in 0..self.ctx.config().mouse_bindings().len() { // If mouse mode is active, also look for bindings without shift.
let mut binding = self.ctx.config().mouse_bindings()[i].clone(); let mut check_fallback = mouse_mode && mods.contains(ModifiersState::SHIFT);
// Require shift for all modifiers when mouse mode is active.
if mouse_mode {
binding.mods |= ModifiersState::SHIFT;
}
for binding in &mouse_bindings {
if binding.is_triggered_by(mode, mods, &button) { if binding.is_triggered_by(mode, mods, &button) {
binding.action.execute(&mut self.ctx); binding.action.execute(&mut self.ctx);
check_fallback = false;
}
}
if check_fallback {
let fallback_mods = mods & !ModifiersState::SHIFT;
for binding in &mouse_bindings {
if binding.is_triggered_by(mode, fallback_mods, &button) {
binding.action.execute(&mut self.ctx);
}
} }
} }
} }

View file

@ -583,9 +583,10 @@ This section documents the *[mouse]* table of the configuration file.
See _keyboard.bindings_ for full documentation on _mods_, _mode_, _action_, See _keyboard.bindings_ for full documentation on _mods_, _mode_, _action_,
and _chars_. and _chars_.
To trigger mouse bindings when an application running within Alacritty When an application running within Alacritty captures the mouse, the `Shift`
captures the mouse, the `Shift` modifier is automatically added as a modifier can be used to suppress mouse reporting. If no action is found for
requirement. the event, actions for the event without the `Shift` modifier are triggered
instead.
*mouse* "Middle" | "Left" | "Right" | "Back" | "Forward" | <number> *mouse* "Middle" | "Left" | "Right" | "Back" | "Forward" | <number>