diff options
Diffstat (limited to 'src/Kind.zig')
| -rw-r--r-- | src/Kind.zig | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/Kind.zig b/src/Kind.zig index 27cd1a6d..bdbfeb2e 100644 --- a/src/Kind.zig +++ b/src/Kind.zig @@ -134,7 +134,7 @@ pub const Slot = struct { // jobs' inputs, its file's hash, a placeholder's record, the place // its kind says), and what a frame makes (the thumb, the pointer, // whether one was drawn: a view's, never a step's). - .local = .{ "ops", "st", "gpa", "arena", "opened", "jobs", "tokens", "record", "where_text", "thumb_at", "thumb_span", "pointer", "painted", "over", "shadow", "used" }, + .local = .{ "ops", "st", "gpa", "arena", "opened", "reloads", "jobs", "tokens", "record", "where_text", "thumb_at", "thumb_span", "pointer", "painted", "over", "shadow", "used" }, }; /// Its kind's code here; null in a placeholder (`live` false: its kind /// not in the registry, its record kept for the day it comes) or a @@ -150,6 +150,10 @@ pub const Slot = struct { /// The hash of the file's bytes it was opened from, 0 for none (a /// record's): whether the file a watch arms on is still those. opened: u64 = 0, + /// Times its file changed under it (fileChanged): its pictures' keys + /// carry it, since its kind numbers them afresh from each open, and a + /// frontend keeps what it uploaded by key. + reloads: u32 = 0, /// Its kind's generation when it was opened (Entry.gen). gen: u32 = 0, path: []u8 = &.{}, @@ -248,6 +252,9 @@ pub fn open(p: *Pardes, id: usize, k: u8, path: ?[]const u8, bytes: ?[]const u8) const pane = try p.newDocPane(id); pane.addon = s; _ = reopen(p, id, s, bytes); + // Its file watched, as a text's is: changed on disk, it opens again + // from it (fileChanged); retirePane lets the watch go. + if (s.path.len > 0 and @import("fs.zig").localPath(s.path) != null) p.emit(.{ .watch = .{ .pane = @intCast(id), .on = true } }); return pane; } @@ -346,6 +353,7 @@ pub fn fileChanged(p: *Pardes, id: usize, _: []const u8) bool { if (checked) s.used.clearRetainingCapacity(); if (s.record) |r| s.gpa.free(r); s.record = record; + s.reloads +%= 1; return reopen(p, id, s, bytes orelse ""); } @@ -445,6 +453,10 @@ pub fn paint(p: *const Pardes, slot: *Slot, id: usize, arena: std.mem.Allocator, continue; } frame.buf[frame.n] = pl; + if (slot.reloads != 0) { + frame.buf[frame.n].key = std.hash.Wyhash.hash(slot.reloads, std.mem.asBytes(&pl.key)); + if (pl.from != 0) frame.buf[frame.n].from = std.hash.Wyhash.hash(slot.reloads, std.mem.asBytes(&pl.from)); + } frame.n += 1; } slot.thumb_at = std.math.clamp(out.at, 0, 1); |
