summaryrefslogtreecommitdiff
path: root/core/mouse.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-19 20:31:32 -0300
committerGabriel Schneider <[email protected]>2026-11-19 20:31:32 -0300
commit0db34fbf28e70c8c6a3c6025c0888fc5ec75201c (patch)
treef2e288668decded9276ebc45907f16d651b06f9e /core/mouse.zig
parent2ab05b536bc3b063666b5aaab497157adc2a9120 (diff)
parentbf351b62e8843a3d173cedeefa2dd0b8ef4b4392 (diff)
downloadpardes-0db34fbf28e70c8c6a3c6025c0888fc5ec75201c.tar.gz
pardes-0db34fbf28e70c8c6a3c6025c0888fc5ec75201c.zip
integration: a pane's and a view's slot as types, with the regular-expression fixes and the fixes the real loops asked for: pardes-ids (Pane.Id and View.Id through the entries, the events, the effects, the Host table and the device messages) and pardes-merge21, merged without a textual conflict; one call site written since on the old type follows (core/draw.zig: the twin test's file_changed event, .pane = .at(0)); tui core-test 848/991 (143 skipped), shell-test 1027/1030, the window builds; gates in the coordinator's ledger
Co-Authored-By: Claude Fable 5.2 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'core/mouse.zig')
-rw-r--r--core/mouse.zig28
1 files changed, 14 insertions, 14 deletions
diff --git a/core/mouse.zig b/core/mouse.zig
index 5707cb57..3d7c5af9 100644
--- a/core/mouse.zig
+++ b/core/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.editor(), t) catch |err| return p.reportError(v.active, "edit", err);
+ const text = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(.at(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");
@@ -103,7 +103,7 @@ fn headerSweepRun(p: *Pardes, sweep: HeaderSweep) void {
const under = if (tagline.wordBoundsAtCol(bar, at)) |b| bar[b.lo..b.hi] else "";
break :click if (on) |sp| (if (at >= sp.lo and at < sp.hi) bar[sp.lo..sp.hi] else under) else under;
};
- const word = p.scratch.allocator().dupe(u8, selected) catch |err| return p.reportError(v.active, "edit", err);
+ const word = p.scratch.allocator().dupe(u8, selected) catch |err| return p.reportError(.at(v.active), "edit", err);
tagline.exitHeader(p);
// A column tag's command acts on that column, empty or not.
p.exec_column = column;
@@ -821,7 +821,7 @@ pub fn handleMouse(p: *Pardes, event: Mouse) void {
// acme 1-2 / 1-3: the execute (Cut) or look (Paste) button
// tapped while the select button holds a selection drag
if (v.drag == .select and v.drag.select.button == config.select_button) {
- chordCutPaste(p, m.button == config.exec_button) catch |err| p.reportError(v.active, "edit", err);
+ chordCutPaste(p, m.button == config.exec_button) catch |err| p.reportError(.at(v.active), "edit", err);
return;
}
// acme 2-3 / 3-2: tapping the OTHER of execute/look during
@@ -1089,7 +1089,7 @@ fn mirrorTtySelection(p: *Pardes, pane: *Pane) void {
if (rows.len == 0) return;
const forward = gesture.r1 > gesture.r0 or (gesture.r1 == gesture.r0 and gesture.c1 >= gesture.c0);
const endpoint = rows[if (forward) rows.len - 1 else 0];
- const body = body_layer.bodyText(p.settings.tab, p.scratch.allocator(), pane) catch |err| return p.reportError(p.view().active, "select", err);
+ const body = body_layer.bodyText(p.settings.tab, p.scratch.allocator(), pane) catch |err| return p.reportError(.at(p.view().active), "select", err);
const line = modal.lineSlice(body, @intCast(@max(0, endpoint.row - @as(i32, @intCast(panes.Term.grid(pane.terminal).offset)))));
const byte = if (forward) modal.prevGrapheme(line, @min(endpoint.hi, line.len)) else endpoint.lo;
pane.body.cur_row = pane.surfRow(endpoint.row);
@@ -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.editor(), text) catch |err| p.reportError(p.view().active, "yank", err);
+ edit.setYank(p.editor(), text) catch |err| p.reportError(.at(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.editor(), t) catch |err| return p.reportError(v.active, "edit", err);
+ const text = edit.flatSurface(p.editor(), t) catch |err| return p.reportError(.at(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;
@@ -1213,7 +1213,7 @@ fn dragRelease(p: *Pardes, button: Mouse.Button) void {
}
return;
}
- if (dragged and s.anchor == null) edit.capturePointerSelection(p, pane, sel_slot) catch |err| p.reportError(s.id, "select", err);
+ if (dragged and s.anchor == null) edit.capturePointerSelection(p, pane, sel_slot) catch |err| p.reportError(.at(s.id), "select", err);
if (dragged and pane.body.mode == .tty) mirrorTtySelection(p, pane);
const body_vis = sl.r1 - @as(i32, pane.tag_rows);
if (body_vis >= 0 and pane.body.mode != .tty) {
@@ -1580,17 +1580,17 @@ test "a wheel over a program that owns it is the program's, in the form it asked
.{ .modes = "\x1b[?1007l", .button = .wheel_up, .sent = "" },
};
for (cases) |case| {
- p.update(.{ .output = .{ .pane = 0, .bytes = case.modes } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = case.modes } });
_ = pardes.test_api.ptyBytes(p, 0, &out);
p.update(.{ .mouse = .{ .button = case.button, .kind = .press, .col = col, .row = row, .ctrl = case.ctrl, .alt = case.alt, .shift = case.shift } });
try std.testing.expectEqualStrings(case.sent, pardes.test_api.ptyBytes(p, 0, &out));
}
// A shell on the main screen: the wheel scrolls its scrollback, and
// the shell hears nothing.
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1l\x1b[?1049l" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1l\x1b[?1049l" } });
for (0..40) |i| {
var line: [16]u8 = undefined;
- p.update(.{ .output = .{ .pane = 0, .bytes = try std.fmt.bufPrint(&line, "{d}\r\n", .{i}) } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = try std.fmt.bufPrint(&line, "{d}\r\n", .{i}) } });
}
_ = try p.render(frame.allocator());
_ = pardes.test_api.ptyBytes(p, 0, &out);
@@ -1600,7 +1600,7 @@ test "a wheel over a program that owns it is the program's, in the form it asked
try std.testing.expect(pane.scroll() != was);
// A program tracking the mouse on the main screen: Shift and the
// wheel scroll the scrollback, the program hears nothing.
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1000h\x1b[?1006h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1000h\x1b[?1006h" } });
_ = pardes.test_api.ptyBytes(p, 0, &out);
const tracked = pane.scroll();
p.update(.{ .mouse = .{ .button = .wheel_up, .kind = .press, .col = col, .row = row, .shift = true } });
@@ -1671,7 +1671,7 @@ test "a program tracking the mouse gets its clicks, drags and moves over its gri
}
}.f;
// htop's modes: clicks in SGR, a release its own `m`.
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1049h\x1b[?1h\x1b[?1006;1000h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1049h\x1b[?1h\x1b[?1006;1000h" } });
_ = pardes.test_api.ptyBytes(p, 0, &out);
try std.testing.expectEqualStrings("\x1b[<0;6;4M", try send(p, &out, col, row, .{ .button = .left, .kind = .press }));
try std.testing.expect(p.view().drag == .none);
@@ -1713,7 +1713,7 @@ test "a program tracking the mouse gets its clicks, drags and moves over its gri
// codex's any-event tracking: a drag once per cell, carried past the
// grid's edge and clamped there, and bare moves.
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1003h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1003h" } });
_ = pardes.test_api.ptyBytes(p, 0, &out);
try std.testing.expectEqualStrings("\x1b[<35;9;4M", try send(p, &out, col, row, .{ .button = .none, .kind = .motion, .dx = 3 }));
try std.testing.expectEqualStrings("", try send(p, &out, col, row, .{ .button = .none, .kind = .motion, .dx = 3 }));
@@ -1737,7 +1737,7 @@ test "a program tracking the mouse gets its clicks, drags and moves over its gri
// Legacy X10 bytes: a release is button 3. (Turning 1003 off turns
// tracking off, as xterm's one tracking mode goes.)
- p.update(.{ .output = .{ .pane = 0, .bytes = "\x1b[?1003l\x1b[?1006l\x1b[?1000h" } });
+ p.update(.{ .output = .{ .pane = .at(0), .bytes = "\x1b[?1003l\x1b[?1006l\x1b[?1000h" } });
_ = pardes.test_api.ptyBytes(p, 0, &out);
try std.testing.expectEqualStrings("\x1b[M &$", try send(p, &out, col, row, .{ .button = .left, .kind = .press }));
try std.testing.expectEqualStrings("\x1b[M#&$", try send(p, &out, col, row, .{ .button = .left, .kind = .release }));