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.
This commit is contained in:
parent
14884deba7
commit
09b78dc80a
26
src/input.rs
26
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;
|
let height = self.ctx.size_info().cell_height as i32;
|
||||||
|
|
||||||
while self.ctx.mouse_mut().scroll_px.abs() >= height {
|
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) {
|
if self.ctx.terminal_mode().intersects(mode::ALT_SCREEN_BUF) {
|
||||||
// Faux scrolling
|
// Faux scrolling
|
||||||
if self.ctx.mouse_mut().scroll_px > 0 {
|
if button == 64 {
|
||||||
// Scroll up three lines
|
// Scroll up one line
|
||||||
self.ctx.write_to_pty("\x1bOA\x1bOA\x1bOA".as_bytes());
|
self.ctx.write_to_pty("\x1bOA".as_bytes());
|
||||||
} else {
|
} else {
|
||||||
// Scroll down three lines
|
// Scroll down one line
|
||||||
self.ctx.write_to_pty("\x1bOB\x1bOB\x1bOB".as_bytes());
|
self.ctx.write_to_pty("\x1bOB".as_bytes());
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
self.normal_mouse_report(button);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue