Merge pull request #1893 from ghostty-org/scroll-full

core: mouse within top/bottom 1 pixel should scroll selection
This commit is contained in:
Mitchell Hashimoto
2024-06-29 00:49:34 -04:00
committed by GitHub

View File

@ -2567,10 +2567,12 @@ pub fn cursorPosCallback(
// If our y is negative, we're above the window. In this case, we scroll // If our y is negative, we're above the window. In this case, we scroll
// up. The amount we scroll up is dependent on how negative we are. // up. The amount we scroll up is dependent on how negative we are.
// We allow for a 1 pixel buffer at the top and bottom to detect
// scroll even in full screen windows.
// Note: one day, we can change this from distance to time based if we want. // Note: one day, we can change this from distance to time based if we want.
//log.warn("CURSOR POS: {} {}", .{ pos, self.screen_size }); //log.warn("CURSOR POS: {} {}", .{ pos, self.screen_size });
const max_y: f32 = @floatFromInt(self.screen_size.height); const max_y: f32 = @floatFromInt(self.screen_size.height);
if (pos.y < 0 or pos.y > max_y) { if (pos.y <= 1 or pos.y > max_y - 1) {
const delta: isize = if (pos.y < 0) -1 else 1; const delta: isize = if (pos.y < 0) -1 else 1;
try self.io.terminal.scrollViewport(.{ .delta = delta }); try self.io.terminal.scrollViewport(.{ .delta = delta });