summaryrefslogtreecommitdiff
path: root/core/look.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/look.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/look.zig')
-rw-r--r--core/look.zig58
1 files changed, 29 insertions, 29 deletions
diff --git a/core/look.zig b/core/look.zig
index e075bbae..f7084079 100644
--- a/core/look.zig
+++ b/core/look.zig
@@ -311,7 +311,7 @@ pub fn submitSearch(p: *Pardes, id: usize) void {
if (normal.selRegexArmed(pane)) |a| {
// helix keeps the pattern in `/`
if (a.pat.len > 0) {
- p.registers.put(p.gpa, '/', a.pat, 0, 1, true) catch |err| return p.reportError(id, "search", err);
+ p.registers.put(p.gpa, '/', a.pat, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err);
p.registers.last_search = '/';
}
return if (panes.promptTarget(p, pane)) |t| normal.applySelRegex(p, pane, t, a.pat, a.mode);
@@ -321,10 +321,10 @@ pub fn submitSearch(p: *Pardes, id: usize) void {
if (std.mem.startsWith(u8, armed, config.rename_marker)) return p.lspRequest(id, .rename, armed[slash + 1 ..]);
if (std.mem.startsWith(u8, armed, config.symbol_marker)) return p.lspRequest(id, .workspace_symbols, armed[slash + 1 ..]);
// A PDF's `/` and a terminal's: a text's is its query pane (Query.zig).
- _ = runSearch(p, id, armed[slash + 1 ..], .top, true) catch |err| return p.reportError(id, "search", err);
+ _ = runSearch(p, id, armed[slash + 1 ..], .top, true) catch |err| return p.reportError(.at(id), "search", err);
var pattern: std.ArrayList(u8) = .empty;
- normal.appendSearchLiteral(&pattern, p.scratch.allocator(), armed[slash + 1 ..]) catch |err| return p.reportError(id, "search", err);
- p.registers.put(p.gpa, '/', pattern.items, 0, 1, true) catch |err| return p.reportError(id, "search", err);
+ normal.appendSearchLiteral(&pattern, p.scratch.allocator(), armed[slash + 1 ..]) catch |err| return p.reportError(.at(id), "search", err);
+ p.registers.put(p.gpa, '/', pattern.items, 0, 1, true) catch |err| return p.reportError(.at(id), "search", err);
p.registers.last_search = '/';
lookFirstHit(p, id);
}
@@ -756,7 +756,7 @@ pub fn focusPaneLine(p: *Pardes, id: usize, at: Spot, landing: enum { center, ke
}
fn selectSpan(p: *Pardes, pane: *Pane, at: Spot) void {
- const text = edit.flatSurface(p.editor(), &pane.body) catch |err| return p.reportError(p.view().active, "look", err);
+ const text = edit.flatSurface(p.editor(), &pane.body) catch |err| return p.reportError(.at(p.view().active), "look", err);
// saturating, not `- 1`: `f.zig:0-5` is a legal thing to type and a
// 1-based zero is the same nothing an absent number is
const acol: i32 = @intCast(at.col -| 1);
@@ -952,7 +952,7 @@ fn missed(p: *Pardes, id: usize, comptime fmt: []const u8, args: anytype) void {
var msg: Kind.Buf(miss_path_cap + 72) = .{};
// Shown on the pane; logged once, as the err below, not a msg too.
p.fs.unlogged = true;
- p.setMessage(id, msg.print("Look: {s}", .{why}));
+ p.setMessage(.at(id), msg.print("Look: {s}", .{why}));
p.fs.unlogged = false;
const serial = if (p.panes[id]) |pane| pane.serial else 0;
var rec: Kind.Buf(miss_path_cap + 96) = .{};
@@ -1047,7 +1047,7 @@ fn lookUnresolved(p: *Pardes, id: usize, pane: *Pane, trimmed: []const u8, text:
p.word_look = true;
defer p.word_look = false;
const rows = runSearch(p, id, text, .cursor, false) catch |err| {
- p.reportError(id, "search", err);
+ p.reportError(.at(id), "search", err);
return;
};
if (rows == 0) {
@@ -1123,7 +1123,7 @@ fn lookAddress(p: *Pardes, id: usize, path: []const u8, expr: []const u8) void {
var placed: Kind.Buf(miss_path_cap + "…".len + 24) = .{};
const place = placed.print("{s}:{d}", .{ name, line });
if (!opened_here) return missedLine(p, target, place, line);
- p.removePane(target, null) catch |err| p.reportError(id, "look", err);
+ p.removePane(target, null) catch |err| p.reportError(.at(id), "look", err);
if (p.panes[id] != null) v.active = id;
return missedLine(p, id, place, line);
} else |_| {}
@@ -1163,7 +1163,7 @@ fn lookKind(p: *Pardes, id: usize, target: usize, expr_raw: []const u8, opened:
if (opened) {
var kept: [miss_path_cap + "…".len]u8 = undefined;
@memcpy(kept[0..name.len], name);
- p.removePane(target, null) catch |err| p.reportError(id, "look", err);
+ p.removePane(target, null) catch |err| p.reportError(.at(id), "look", err);
if (p.panes[id] != null) p.view().active = id;
return missed(p, id, "{s} {s}", .{ kept[0..name.len], if (said.len > 0) said.slice() else "is no text to address" });
}
@@ -1179,7 +1179,7 @@ fn spotText(at: Spot, buf: *[41]u8) []const u8 {
fn closeAndMiss(p: *Pardes, id: usize, opened: usize, name: []const u8, why: []const u8) void {
var kept: [miss_path_cap + "…".len]u8 = undefined;
@memcpy(kept[0..name.len], name);
- p.removePane(opened, null) catch |err| p.reportError(id, "look", err);
+ p.removePane(opened, null) catch |err| p.reportError(.at(id), "look", err);
if (p.panes[id] != null) p.view().active = id;
missed(p, id, "{s}: {s}", .{ kept[0..name.len], why });
}
@@ -1197,8 +1197,8 @@ fn lookTerminalAddress(p: *Pardes, id: usize, target: usize, expr: []const u8) v
var dot: u32 = 0;
for (lines, 0..) |ln, i| {
if (i == row) dot = @intCast(text.items.len + @min(ln.len, @as(usize, @intCast(@max(0, pane.body.cur_col)))));
- text.appendSlice(arena, ln) catch |err| return p.reportError(id, "look", err);
- text.append(arena, '\n') catch |err| return p.reportError(id, "look", err);
+ text.appendSlice(arena, ln) catch |err| return p.reportError(.at(id), "look", err);
+ text.append(arena, '\n') catch |err| return p.reportError(.at(id), "look", err);
}
var a: Addr = .{ .text = text.items, .lim = null, .expr = expr };
const r = a.address(.{ .q0 = dot, .q1 = dot }) orelse return missed(p, id, "{s}", .{a.err});
@@ -1266,7 +1266,7 @@ pub fn reopenAt(p: *Pardes, from: usize, path: []const u8, at: Spot) void {
if (at.line > n or at.end_line > n) {
var said: Kind.Buf(miss_path_cap + 64) = .{};
var cut: [miss_path_cap + "…".len]u8 = undefined;
- p.setMessage(id, said.print("{s} has {d} lines now: at its last", .{ missText(path, &cut), n }));
+ p.setMessage(.at(id), said.print("{s} has {d} lines now: at its last", .{ missText(path, &cut), n }));
}
}
@@ -1393,7 +1393,7 @@ fn settleLine(p: *Pardes, id: usize, path: []const u8, at: Spot, before: usize,
const shown = p.panes[p.view().active] orelse return;
const f = if (shown.file) |*file| file else return;
if (at.line > panes.File.nlines(p.gpa, f)) {
- if (opened) |free| p.removePane(free, null) catch |err| p.reportError(id, "look", err);
+ if (opened) |free| p.removePane(free, null) catch |err| p.reportError(.at(id), "look", err);
if (p.panes[before] != null) p.view().active = before;
return missedLine(p, id, path, at.line);
}
@@ -1415,7 +1415,7 @@ fn focusPaneByPath(p: *Pardes, path: []const u8, at: Spot) bool {
/// A file that is there but would not open: said with its path, `look:
/// <path>: permission denied`, the path cut in its middle when long.
fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void {
- if (@import("Messages.zig").dialReason(err) != null) return p.reportError(id, path, err);
+ if (@import("Messages.zig").dialReason(err) != null) return p.reportError(.at(id), path, err);
var cut: [miss_path_cap + "…".len]u8 = undefined;
// Not there, on a peer's mount as on this host: a miss, the write
// answered, as any path to no file is.
@@ -1423,7 +1423,7 @@ fn lookOpenFailed(p: *Pardes, id: usize, path: []const u8, err: anyerror) void {
if (err == error.FileNotFound or err == error.NotFound or remote_missing)
return missed(p, id, "{s}: no such file", .{missText(path, &cut)});
var said: Kind.Buf(miss_path_cap + 16) = .{};
- p.reportError(id, said.print("look: {s}", .{missText(path, &cut)}), err);
+ p.reportError(.at(id), said.print("look: {s}", .{missText(path, &cut)}), err);
}
pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
@@ -1468,7 +1468,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
break :looked operand;
};
// The operand may borrow selected terminal/PDF text released below.
- const txt = p.scratch.allocator().dupe(u8, looked) catch |err| return p.reportError(id, "look", err);
+ const txt = p.scratch.allocator().dupe(u8, looked) catch |err| return p.reportError(.at(id), "look", err);
// A trailing `:` (`a.txt:2:3:`, as a compiler's message ends) is no
// part of the place, as a click's expansion leaves it off.
const bare = std.mem.trimEnd(u8, std.mem.trim(u8, txt, " \t\r\n"), ":");
@@ -1586,7 +1586,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
const before = v.active;
var opened: ?usize = null;
if (!focusPaneByPath(p, target.path, target.at)) {
- const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots);
+ const free = p.freeSlot() orelse return p.reportError(.at(id), "look", error.NoPaneSlots);
const nt = panes.File.open(p, free, target.path, target.at.line) catch |err|
return lookOpenFailed(p, id, target.path, err);
if (target.at.col > 0) nt.body.cur_col = @intCast(target.at.col - 1);
@@ -1624,7 +1624,7 @@ pub fn lookAt(p: *Pardes, id: usize, operand_raw: []const u8) void {
if (target.at.line > 0) lookKind(p, id, v.active, spotText(target.at, &place), false);
return;
}
- const free = p.freeSlot() orelse return p.reportError(id, "look", error.NoPaneSlots);
+ const free = p.freeSlot() orelse return p.reportError(.at(id), "look", error.NoPaneSlots);
const made = Kind.openFile(p, free, target.kind, target.path) catch |err|
return lookOpenFailed(p, id, target.path, err);
// One its kind refuses (an image corrupt, truncated, not what
@@ -1923,7 +1923,7 @@ test "Look hover waits without mutating the pane and input cancels it" {
// Background traffic in another pane does not change the text or geometry
// under this pointer and must not strand a stationary hover unarmed.
- p.update(.{ .output = .{ .pane = @intCast(other_id), .bytes = "busy\r\n" } });
+ p.update(.{ .output = .{ .pane = .at(other_id), .bytes = "busy\r\n" } });
try std.testing.expect(p.look_hover_preview != null);
const seam_x = p.view().col_x[0] + p.view().col_w[0] - 1;
@@ -1975,19 +1975,19 @@ test "cwd changes cancel only the affected pane's Look hover" {
const first = p.panes[0] orelse return error.MissingFirstPane;
const other = p.panes[1] orelse return error.MissingOtherPane;
- p.setCwd(0, "/work/first");
- p.setCwd(1, "/work/other");
+ p.setCwd(.at(0), "/work/first");
+ p.setCwd(.at(1), "/work/other");
p.look_hover_wait = .{ .col = 1, .row = 1, .pane = 0, .serial = first.serial };
// Hosts poll cwd every frame. An unchanged answer is observational and a
// change reported for another pane cannot invalidate this pane's operand.
- p.setCwd(0, "/work/first");
+ p.setCwd(.at(0), "/work/first");
try std.testing.expect(p.look_hover_wait != null);
- p.setCwd(1, "/work/elsewhere");
+ p.setCwd(.at(1), "/work/elsewhere");
try std.testing.expect(p.look_hover_wait != null);
try std.testing.expectEqual(other.serial, p.panes[1].?.serial);
- p.setCwd(0, "/work/changed");
+ p.setCwd(.at(0), "/work/changed");
try std.testing.expect(p.look_hover_wait == null);
try std.testing.expect(p.look_hover_preview == null);
}
@@ -2504,9 +2504,9 @@ test "LookNext in a command pane walks its own file:line places, whoever walked
while (p.nextEffect()) |_| {}
const dst = exec.execute(p, 0, "make") orelse return error.NoCommandPane;
while (p.nextEffect()) |_| {}
- p.update(.{ .output = .{ .pane = @intCast(dst), .bytes = "x.c:3:1: error: bad\r\ny.c:2:1: warning: odd\r\n" } });
- p.update(.{ .exited = .{ .pane = @intCast(dst), .status = 2 } });
- p.update(.{ .eof = .{ .pane = @intCast(dst) } });
+ p.update(.{ .output = .{ .pane = .at(dst), .bytes = "x.c:3:1: error: bad\r\ny.c:2:1: warning: odd\r\n" } });
+ p.update(.{ .exited = .{ .pane = .at(dst), .status = 2 } });
+ p.update(.{ .eof = .{ .pane = .at(dst) } });
const cmd = p.panes[dst].?;
// A walk last made elsewhere, and another pane with places in it.
try std.testing.expect(p.executeBuiltinLine(0, "New"));
@@ -2671,7 +2671,7 @@ test "Plumb: a look sends what it looks at, the rules written first: a rule's wo
const opened = p.view().active;
try std.testing.expect(opened != 0);
p.view().active = 0;
- p.setMessage(0, "before");
+ p.setMessage(.at(0), "before");
lookAt(p, 0, pic);
try std.testing.expectEqual(opened, p.view().active);
try std.testing.expectEqualStrings("before", pane.msg[0..pane.msg_len]);