surface: add timer-based scrolling during selection

This commit is contained in:
moni-dz
2025-01-02 13:12:11 +08:00
committed by Mitchell Hashimoto
parent c00b8740aa
commit f73c90bf5d
4 changed files with 55 additions and 12 deletions

View File

@@ -495,17 +495,13 @@ fn selectionScrollCallback(
};
const cb = cb_ orelse return .disarm;
const surface = cb.io.surface_mailbox.surface;
const pos = try surface.rt_surface.getCursorPos();
const delta: isize = if (pos.y < 0) -1 else 1;
const self = cb.self;
try cb.io.terminal.scrollViewport(.{ .delta = delta });
_ = cb.io.surface_mailbox.push(.{ .selection_scroll = self.scroll_active }, .{ .instant = {} });
// Notify the renderer that it should repaint immediately after scrolling
cb.io.renderer_wakeup.notify() catch {};
const self = cb.self;
if (self.scroll_active) {
self.scroll.run(&self.loop, &self.scroll_c, selection_scroll_ms, CallbackData, cb, selectionScrollCallback);
}