diff options
Diffstat (limited to 'core/File.zig')
| -rw-r--r-- | core/File.zig | 24 |
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 }); |
