diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-17 07:44:55 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-17 12:15:01 -0300 |
| commit | 0db7861d9da09e059fa1b9e40fff5cd52add27f2 (patch) | |
| tree | 6e95dfa36e07b3234b1d5cdb990b11f95c184a3f /src/mouse.zig | |
| parent | d3742ddf2b3a85eb3935cb35e958fa27f1293a6b (diff) | |
| parent | dee94c740bdaea61ff35b4e0a7f1d2815c9ee441 (diff) | |
| download | pardes-0db7861d9da09e059fa1b9e40fff5cd52add27f2.tar.gz pardes-0db7861d9da09e059fa1b9e40fff5cd52add27f2.zip | |
integration: the text pane a library (pardes-editor), with the GPU move, the terminal, the plumber and the diff work
A merge of pardes-next (wmrtztwl) and editor-lib (rlumrxuq), no conflicts. Gated against the baseline of the integration line (.scratch/sketch/gpu/mbase): the merge with the library before its follow-up, in full: frame corpus 77/77 identical in Debug and in ReleaseFast, the gated window -0.019% instructions (threshold 0.5%), unit-test on gui 1584/1592 with no failure the baseline has not; this merge: corpus 77/77 in Debug, unit-test on gui 1584/1592, on tui core-test 811/950 (139 skipped), shell-test 990/993, lib-test, hxdiff 658, parity 738, hxgolf 124, hxlib 538 and its parity 618, all 0 mismatches, replicas pass.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'src/mouse.zig')
| -rw-r--r-- | src/mouse.zig | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/mouse.zig b/src/mouse.zig index 8867982c..4eb18141 100644 --- a/src/mouse.zig +++ b/src/mouse.zig @@ -91,7 +91,7 @@ fn headerSweepRun(p: *Pardes, sweep: HeaderSweep) void { const v = p.view(); const column = sweep.column(p) catch return; // error.Gone: its column closed under the sweep const t = if (column) |c| &v.col_tags[c] else &p.global_tag; - const text = edit.flatSurface(p, t) catch |err| return p.reportError(v.active, "edit", err); + const text = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(v.active, "edit", err); const swept = sweep.span(text.len); const selected = if (swept.lo < swept.hi) text[swept.lo..swept.hi] else click: { const line = std.mem.count(u8, text[0..swept.lo], "\n"); @@ -364,7 +364,7 @@ fn headerPoint(p: *Pardes, column: ?usize, mcol: u16, mrow: u16, clamp: bool) ?s const t = if (column) |c| &v.col_tags[c] else &p.global_tag; const x = if (column) |c| v.col_x[c] + TAG_TEXT_INSET else TAG_TEXT_INSET; const focused = v.header != null and p.headerColumn() == column; - const text = edit.flatSurface(p, t) catch return null; + const text = edit.flatSurface(p.editor(), t) catch return null; const base = if (column != null) p.topBarHeight() else 0; const rows = if (column != null) layout.columnBarHeight(p) else p.topBarHeight(); const row: u16 = if (clamp) @min(mrow -| base, rows -| 1) else mrow -| base; @@ -412,10 +412,10 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void { t.nsel = 0; } if (cut) { - if (t.vsel.active) try edit.normalDelete(p, t, true); + if (t.vsel.active) try edit.normalDelete(p.editor(), t, true); } else if (t.vsel.active) { - try edit.chordReplace(p, t); - } else try edit.pasteText(p, t, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1); + try edit.chordReplace(p.editor(), t); + } else try edit.pasteText(p.editor(), t, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1); return; } if (pane.body.mode == .tty) { @@ -444,7 +444,7 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void { // Everything done while B1 stays down is one undo step, as acme // marks the file once per B1 hold (text.c:881 textselect, `state` // and its one filemark): B1-B2 then B1-B3 is a copy. - try edit.pushUndo(p, &pane.body); + try edit.pushUndo(p.editor(), &pane.body); p.view().chord_hold = true; const sl = pane.sel[sel_slot]; pane.sel[sel_slot].state = .none; @@ -455,8 +455,8 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void { const w1 = pane.wrapAt(@max(0, sl.r1 - @as(i32, pane.tag_rows))); const row0 = w0.line; const row1 = w1.line; - const col0 = edit.paneByteAtDisplay(p, &pane.body, w0.line, w0.at, sl.c0 - pfx - w0.pad); - const col1 = edit.paneByteAtDisplay(p, &pane.body, w1.line, w1.at, sl.c1 - pfx - w1.pad); + const col0 = edit.paneByteAtDisplay(p.editor(), &pane.body, w0.line, w0.at, sl.c0 - pfx - w0.pad); + const col1 = edit.paneByteAtDisplay(p.editor(), &pane.body, w1.line, w1.at, sl.c1 - pfx - w1.pad); pane.body.cur_row = row1; pane.body.cur_col = col1; pane.body.cur_pinned = true; @@ -466,16 +466,16 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void { pane.body.nsel = 0; } if (cut) { - if (pane.body.vsel.active) try edit.normalDelete(p, &pane.body, true); + if (pane.body.vsel.active) try edit.normalDelete(p.editor(), &pane.body, true); } else if (pane.body.vsel.active) { - try edit.chordReplace(p, &pane.body); + try edit.chordReplace(p.editor(), &pane.body); } else if (pane.file) |*f| { // bare cursor: splice the register in literally (no linewise // magic) so a paste right after a cut restores the text exactly const y = p.registers.text(p.gpa, pardes.Registers.default) orelse return; if (y.len == 0) return; const at = modal.Cursor{ .row = @intCast(@max(0, pane.body.cur_row)), .col = @intCast(@max(0, pane.body.cur_col)) }; - try edit.pushUndo(p, &pane.body); + try edit.pushUndo(p.editor(), &pane.body); const new = try modal.insertAt(p.gpa, f.content, at, y); panes.File.setContent(p, f, new); pane.body.vsel = .{ .active = modal.nextGrapheme(y, 0) < y.len, .row = @intCast(at.row), .col = @intCast(at.col), .explicit = false }; @@ -491,7 +491,7 @@ fn chordCutPaste(p: *Pardes, cut: bool) edit.Error!void { pane.body.cur_pinned = true; pane.body.sticky_col = -1; pane.ensureCursorVisible(); - } else try edit.pasteText(p, &pane.body, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1); + } else try edit.pasteText(p.editor(), &pane.body, p.registers.text(p.gpa, pardes.Registers.default) orelse return, true, 1); } pub fn handleMouse(p: *Pardes, event: Mouse) void { @@ -1042,7 +1042,7 @@ fn gestureRange(p: *Pardes, id: usize, text: []const u8, on_tag: bool, operand: const top = lead[0] - @as(i32, pane.tag_rows); if (top < 0) break :lead null; const w = pane.wrapAt(top); - const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, lead[1] - panes.File.gutterWidth(pane) - w.pad); + const col = edit.paneByteAtDisplay(p.editor(), &pane.body, w.line, w.at, lead[1] - panes.File.gutterWidth(pane) - w.pad); break :lead .{ .row = @intCast(@max(0, w.line)), .col = @intCast(@max(0, col)), @@ -1107,7 +1107,7 @@ fn mirrorTtySelection(p: *Pardes, pane: *Pane) void { pane.body.restore_cursor = false; pane.body.sticky_col = -1; pane.body.normal.clear(); - edit.setYank(p, text) catch |err| p.reportError(p.view().active, "yank", err); + edit.setYank(p.editor(), text) catch |err| p.reportError(p.view().active, "yank", err); } /// acme's double-click (text.c:881 textselect, plan9port text.c:1407 @@ -1124,7 +1124,7 @@ fn doubleClick(p: *Pardes, id: usize, t: *panes.Text, on_tag: bool, row: i32, co const c = prev orelse return; if (c.id != id or c.on_tag != on_tag or c.row != row or c.col != col or now - c.ms > 500) return; v.last_click = null; - const text = edit.flatSurface(p, t) catch |err| return p.reportError(v.active, "edit", err); + const text = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(v.active, "edit", err); const q = modal.offsetAt(text, .{ .row = @intCast(@max(0, t.cur_row)), .col = @intCast(@max(0, t.cur_col)) }); const r = edit.doubleClickRange(text, q); if (r[1] <= r[0]) return; @@ -1160,7 +1160,7 @@ fn sweepPoint(p: *Pardes, pane: *panes.Pane, r: i32, c: i32) ?modal.Cursor { if (visible < 0) return null; const w = pane.wrapAt(visible); if (w.line < 0) return null; - const col = edit.paneByteAtDisplay(p, &pane.body, w.line, w.at, c - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0)); + const col = edit.paneByteAtDisplay(p.editor(), &pane.body, w.line, w.at, c - w.pad - (if (pane.file != null) @as(i32, panes.File.gutterWidth(pane)) else 0)); return .{ .row = @intCast(w.line), .col = @intCast(@max(0, col)) }; } @@ -1220,7 +1220,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void { const w = pane.wrapAt(body_vis); pane.body.cur_row = w.line; pane.body.cur_col = edit.paneByteAtDisplay( - p, + p.editor(), &pane.body, w.line, w.at, |
