summaryrefslogtreecommitdiff
path: root/core/File.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/File.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/File.zig')
-rw-r--r--core/File.zig24
1 files changed, 12 insertions, 12 deletions
diff --git a/core/File.zig b/core/File.zig
index c9ee6b71..020985da 100644
--- a/core/File.zig
+++ b/core/File.zig
@@ -581,13 +581,13 @@ pub fn open(p: *Pardes, id: usize, path: []const u8, line: usize) !*Pane {
pane.body.cur_pinned = true;
pane.body.cur_row = @intCast(scroll);
p.installPane(id, pane);
- if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = true } });
+ if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = .at(id), .on = true } });
return pane;
}
pub fn deinit(p: *Pardes, pane: *Pane, file: *State) void {
if (file.output == null) for (p.panes, 0..) |slot, id| {
- if (slot == pane) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = false } });
+ if (slot == pane) p.emit(.{ .watch = .{ .pane = .at(id), .on = false } });
};
// A twin's text, undo and shared index stay with the twins left.
var twins: [pardes.MAX_PANES]usize = undefined;
@@ -786,7 +786,7 @@ fn edit(p: *Pardes, f: *State, off: usize, len: usize, bytes_in: []const u8, who
f.syntax_dirty = true;
if (f.pager) f.pager_diff = looksLikeDiff(f.content[0..@min(new_len, 64 * 1024)]);
if (undo_gone) for (p.panes, 0..) |slot, id| {
- if (slot) |pane| if (pane.file) |*state| if (state == f) p.setMessage(id, "undo keeps the last two texts replaced whole: the steps before them are gone");
+ if (slot) |pane| if (pane.file) |*state| if (state == f) p.setMessage(.at(id), "undo keeps the last two texts replaced whole: the steps before them are gone");
};
for (twins[0..ntwins], 0..) |id, i| {
const t = p.panes[id].?;
@@ -991,7 +991,7 @@ pub fn zerox(p: *Pardes, from: usize, to: usize) !*Pane {
pane.body.cur_row = src.body.cur_row;
pane.body.cur_col = src.body.cur_col;
pane.body.cur_pinned = true;
- if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = @intCast(to), .on = true } });
+ if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = .at(to), .on = true } });
return pane;
}
@@ -1287,16 +1287,16 @@ fn restoreName(p: *Pardes, pane: *Pane, f: *State, snap: Text.Place) void {
if (slot == pane) break i;
} else return;
// nameBuffer frees nothing of `path`: it keeps the name it ends.
- const back = p.gpa.dupe(u8, path) catch |err| return p.reportError(id, "undo", err);
+ const back = p.gpa.dupe(u8, path) catch |err| return p.reportError(.at(id), "undo", err);
defer p.gpa.free(back);
- pardes.ctlfs.pane.nameBuffer(p, id, back, false) catch |err| return p.reportError(id, "undo", err);
+ pardes.ctlfs.pane.nameBuffer(p, id, back, false) catch |err| return p.reportError(.at(id), "undo", err);
history.gen = snap.gen;
f.saved_hash = snap.saved_hash;
f.saved_len = snap.saved_len;
f.saved_revision = if (snap.clean) f.revision else f.revision -% 1;
f.disk_newer = null;
f.disk_newer_warned = false;
- if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = true } });
+ if (filesystem.localPath(path) != null) p.emit(.{ .watch = .{ .pane = .at(id), .on = true } });
}
pub fn restoreSnap(tab: u16, pane: *Pane, f: *State, snap: Text.Place) void {
@@ -1464,8 +1464,8 @@ const Gap = struct {
/// `<file> deleted on disk (Save writes it again)`, logged `changed
/// <serial> deleted`.
pub const deleted = pardes.tape.taped(deletedInner);
-fn deletedInner(p: *Pardes, id: u8) void {
- const pane = p.panes[id] orelse return;
+fn deletedInner(p: *Pardes, id: Pane.Id) void {
+ const pane = p.panes[id.index()] orelse return;
const f = if (pane.file) |*file| file else return;
if (f.disk_gone) return;
f.disk_gone = true;
@@ -1497,7 +1497,7 @@ pub fn changed(p: *Pardes, id: u8, bytes: []const u8) void {
f.disk_newer = disk;
f.disk_newer_warned = false;
var said: pardes.Kind.Buf(limits.host_path_cap + 64) = .{};
- p.setMessage(id, said.print("{s} changed on disk (get reloads it, Save overwrites it)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}));
+ p.setMessage(.at(id), said.print("{s} changed on disk (get reloads it, Save overwrites it)", .{f.path[0..@min(f.path.len, limits.host_path_cap)]}));
var rec: [16]u8 = undefined;
pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d}", .{pane.serial}) catch unreachable); // a u32 fits 16
return;
@@ -1506,8 +1506,8 @@ pub fn changed(p: *Pardes, id: u8, bytes: []const u8) void {
// Logged as the dirty case is, with what became of it.
var rec: [32]u8 = undefined;
pardes.ctlfs.events.notePath(p, "changed", std.fmt.bufPrint(&rec, "{d} reloaded", .{pane.serial}) catch unreachable); // a u32 fits 32
- pushUndo(p, pane) catch |err| return p.reportError(id, "reload", err);
- const new = p.gpa.dupe(u8, bytes) catch |err| return p.reportError(id, "reload", err);
+ pushUndo(p, pane) catch |err| return p.reportError(.at(id), "reload", err);
+ const new = p.gpa.dupe(u8, bytes) catch |err| return p.reportError(.at(id), "reload", err);
setContent(p, f, new);
f.saved_revision = f.revision;
restoreSnap(p.settings.tab, pane, f, .{ .cur_row = pane.body.cur_row, .cur_col = pane.body.cur_col, .vsel = pane.body.vsel });