From 09b78dc80aef625dcf0796a59da33e7fdb94ba78 Mon Sep 17 00:00:00 2001 From: Christian Duerr Date: Mon, 18 Dec 2017 20:35:57 +0100 Subject: [PATCH] Adapt pixel-based scrolling behavior The pixel-based scrolling behavior has been adapted to be as similar to the line-based one as possible. I still have not been able to test this. But this should have a decent chance to at least kinda work. --- src/input.rs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/input.rs b/src/input.rs index c653d486..7521409c 100644 --- a/src/input.rs +++ b/src/input.rs @@ -407,24 +407,24 @@ impl<'a, A: ActionContext + 'a> Processor<'a, A> { let height = self.ctx.size_info().cell_height as i32; while self.ctx.mouse_mut().scroll_px.abs() >= height { + let button = if self.ctx.mouse_mut().scroll_px > 0 { + self.ctx.mouse_mut().scroll_px -= height; + 64 + } else { + self.ctx.mouse_mut().scroll_px += height; + 65 + }; + if self.ctx.terminal_mode().intersects(mode::ALT_SCREEN_BUF) { // Faux scrolling - if self.ctx.mouse_mut().scroll_px > 0 { - // Scroll up three lines - self.ctx.write_to_pty("\x1bOA\x1bOA\x1bOA".as_bytes()); + if button == 64 { + // Scroll up one line + self.ctx.write_to_pty("\x1bOA".as_bytes()); } else { - // Scroll down three lines - self.ctx.write_to_pty("\x1bOB\x1bOB\x1bOB".as_bytes()); + // Scroll down one line + self.ctx.write_to_pty("\x1bOB".as_bytes()); } } else { - let button = if self.ctx.mouse_mut().scroll_px > 0 { - self.ctx.mouse_mut().scroll_px -= height; - 64 - } else { - self.ctx.mouse_mut().scroll_px += height; - 65 - }; - self.normal_mouse_report(button); } }