From 9660151c94e988620c79b40a0326057b9854c081 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 22:16:35 -0300 Subject: Move the mouse out of pardes.zig into mouse.zig Pure move, no behaviour change: handleMouse with dragUpdate, dragRelease, seamIdxAt, reportGesture, gestureRange, dispatchPointerBuiltin, mirrorTtySelection and chordCutPaste, the pointer hit helpers (bodyHitForPane, sameTagCell, tagColumn, sameBodyCell), chromeTarget with ChromeTarget, paneAt, the Drag state type with clampBorderCol/Row, the seam test fixtures and thirteen pointer and drag tests go verbatim to mouse.zig. The methods become free functions taking `p: *Pardes`; their 36 call sites change from `p.handleMouse(..)` to `mouse.handleMouse(p, ..)`, including web.zig's chromeTarget and macos.zig's paneAt. The Mouse event type stays in pardes.zig with the rest of the event vocabulary. Co-Authored-By: Claude Opus 5.5 --- src/edit.zig | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/edit.zig') diff --git a/src/edit.zig b/src/edit.zig index f829decc..04416b67 100644 --- a/src/edit.zig +++ b/src/edit.zig @@ -3,6 +3,7 @@ //! operations, replace, case, join, indent, comments, numbers, textobjects //! and surround, undo, yank and paste, and the pointer selections as text. const pardes = @import("pardes.zig"); +const mouse = @import("mouse.zig"); const normal = @import("normal.zig"); const std = @import("std"); const modal = @import("modal.zig"); @@ -1533,12 +1534,12 @@ pub fn pointerTextSelection(p: *const Pardes, id: usize, col: u16, row: u16, bod if (!on_tag and row >= body_y and row - body_y < p.panes[id].?.notices.span() and p.panes[id].?.notices.covers(row - body_y, col)) return null; if (!on_tag) if (body_hit) |supplied| { - const mapped_hit = p.bodyHitForPane(id, supplied, false) orelse return null; + const mapped_hit = mouse.bodyHitForPane(p, id, supplied, false) orelse return null; const c = @as(i32, mapped_hit.col) - config.GUTTER; const v = @as(i32, mapped_hit.row) + BOX_H; return .{ .sel = .{ .state = .dragging, .c0 = c, .c1 = c, .r0 = v, .r1 = v }, .on_tag = false }; }; - const tag_col = if (on_tag) p.tagColumn(.pane, id, tag_hit, false) else null; + const tag_col = if (on_tag) mouse.tagColumn(p, .pane, id, tag_hit, false) else null; const c: i32 = (if (tag_col) |value| @as(i32, value) else @as(i32, col) - @as(i32, r.x + (if (on_tag) TAG_TEXT_INSET else config.GUTTER))) + (if (on_tag) @as(i32, p.panes[id].?.tag_scroll) else 0); const v: i32 = if (on_tag) 0 else @as(i32, row) - @as(i32, body_y) + @as(i32, BOX_H); -- cgit v1.3