diff options
author | Joe Wilm <joe@jwilm.com> | 2018-01-06 11:39:33 -0800 |
---|---|---|
committer | Joe Wilm <jwilm@users.noreply.github.com> | 2018-01-06 11:57:38 -0800 |
commit | c44f56e56e8178fbf01e965d28e3679fdf541e16 (patch) | |
tree | 94ec475d87928e6f76965f533c5729f770da4ee5 | |
parent | 2920cbe7103f03a45080bfb7610bd7f481f36361 (diff) | |
download | alacritty-c44f56e56e8178fbf01e965d28e3679fdf541e16.tar.gz alacritty-c44f56e56e8178fbf01e965d28e3679fdf541e16.zip |
Fix SGR mouse reporting
There were two bugs fixed in this commit:
1. `sgr_mouse_report` was not always called when `SGR_MOUSE` bit was set
due to calling `normal_mouse_report` instead of `mouse_report` in the
scrolling method.
2. SGR reporting was always going off the left mouse button state rather
than what was appropriate. This affected SGR scroll reporting since
it only behaves correctly for pressed events (final character 'M').
Resolves #698.
-rw-r--r-- | src/input.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/src/input.rs b/src/input.rs index 823b2f0c..6aae87f9 100644 --- a/src/input.rs +++ b/src/input.rs @@ -284,8 +284,9 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { && ( prev_line != self.ctx.mouse_mut().line || prev_col != self.ctx.mouse_mut().column - ) { - self.mouse_report(32); + ) + { + self.mouse_report(32, ElementState::Pressed); } } } @@ -308,18 +309,20 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { } } - pub fn sgr_mouse_report(&mut self, button: u8, release: bool) { + pub fn sgr_mouse_report(&mut self, button: u8, state: ElementState) { let (line, column) = (self.ctx.mouse_mut().line, self.ctx.mouse_mut().column); - let c = if release { 'm' } else { 'M' }; + let c = match state { + ElementState::Pressed => 'M', + ElementState::Released => 'm', + }; let msg = format!("\x1b[<{};{};{}{}", button, column + 1, line + 1, c); self.ctx.write_to_pty(msg.into_bytes()); } - pub fn mouse_report(&mut self, button: u8) { + pub fn mouse_report(&mut self, button: u8, state: ElementState) { if self.ctx.terminal_mode().contains(mode::TermMode::SGR_MOUSE) { - let release = self.ctx.mouse_mut().left_button_state != ElementState::Pressed; - self.sgr_mouse_report(button, release); + self.sgr_mouse_report(button, state); } else { self.normal_mouse_report(button); } @@ -355,7 +358,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { self.ctx.clear_selection(); let report_modes = mode::TermMode::MOUSE_REPORT_CLICK | mode::TermMode::MOUSE_MOTION; if !modifiers.shift && self.ctx.terminal_mode().intersects(report_modes) { - self.mouse_report(0); + self.mouse_report(0, ElementState::Pressed); return; } @@ -368,7 +371,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { let report_modes = mode::TermMode::MOUSE_REPORT_CLICK | mode::TermMode::MOUSE_MOTION; if !modifiers.shift && self.ctx.terminal_mode().intersects(report_modes) { - self.mouse_report(3); + self.mouse_report(3, ElementState::Released); return; } @@ -429,7 +432,7 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { let faux_scrollback_lines = self.mouse_config.faux_scrollback_lines; if self.ctx.terminal_mode().intersects(mouse_modes) { - self.normal_mouse_report(code); + self.mouse_report(code, ElementState::Pressed); } else if faux_scrollback_lines > 0 { // Faux scrolling let cmd = code + 1; // 64 + 1 = A, 65 + 1 = B |