summaryrefslogtreecommitdiff
path: root/dev/file_watch.zig
diff options
context:
space:
mode:
Diffstat (limited to 'dev/file_watch.zig')
-rw-r--r--dev/file_watch.zig22
1 files changed, 11 insertions, 11 deletions
diff --git a/dev/file_watch.zig b/dev/file_watch.zig
index 9d868e07..84f37c81 100644
--- a/dev/file_watch.zig
+++ b/dev/file_watch.zig
@@ -459,7 +459,7 @@ pub fn reloadPane(
if (pane.file) |file| {
const bytes = filesystem.read(core, file.path) catch |err| {
// Gone from under the pane: said once, the text kept.
- if (err == error.FileNotFound and watched.existed == std.hash.Wyhash.hash(0, file.path)) pardes.panes.File.deleted(core, @intCast(id));
+ if (err == error.FileNotFound and watched.existed == std.hash.Wyhash.hash(0, file.path)) pardes.panes.File.deleted(core, .at(id));
return false;
};
if (watches[id]) |*live| live.existed = std.hash.Wyhash.hash(0, file.path);
@@ -477,7 +477,7 @@ pub fn reloadPane(
};
return false;
}
- if (!core.reloadWatchedFile(@intCast(id), bytes)) return false;
+ if (!core.reloadWatchedFile(.at(id), bytes)) return false;
const current = core.panes[id] orelse return false;
if (current.serial != watched.serial) return false;
const current_file = current.file orelse return false;
@@ -488,7 +488,7 @@ pub fn reloadPane(
}
if (announce) {
var msg_buf: [256]u8 = undefined;
- core.setMessage(id, message.stamp(&msg_buf, "reloaded", current_file.path));
+ core.setMessage(.at(id), message.stamp(&msg_buf, "reloaded", current_file.path));
}
return false;
}
@@ -510,7 +510,7 @@ pub fn reloadPane(
.text => {},
}
// Its kind reads the file again (Kind.fileChanged): on the tape, no bytes.
- if (!core.reloadWatchedFile(@intCast(id), &.{})) return false;
+ if (!core.reloadWatchedFile(.at(id), &.{})) return false;
const current = core.panes[id] orelse return false;
if (current.serial != watched.serial) return false;
const current_path = kindPath(current) orelse return false;
@@ -522,7 +522,7 @@ pub fn reloadPane(
}
if (announce) {
var msg_buf: [256]u8 = undefined;
- core.setMessage(id, message.stamp(&msg_buf, "reloaded", current_path));
+ core.setMessage(.at(id), message.stamp(&msg_buf, "reloaded", current_path));
}
return false;
}
@@ -611,12 +611,12 @@ pub fn applyThemeEffect(
const pane = request.pane;
const bytes = filesystem.readFile(&pardes.tape.none, gpa, request.path) catch |err| {
colors.failThemeFile(core, generation, err);
- core.noteLateFailure(pane);
+ core.noteLateFailure(.at(pane));
return false;
};
defer gpa.free(bytes);
if (!colors.loadThemeFile(core, generation, bytes)) {
- core.noteLateFailure(pane);
+ core.noteLateFailure(.at(pane));
return false;
}
const hash = std.hash.Wyhash.hash(0, bytes);
@@ -659,7 +659,7 @@ pub fn reloadTheme(
live.generation = .{ .text = hash };
if (announce) {
var msg_buf: [256]u8 = undefined;
- core.setMessage(request.pane, message.stamp(&msg_buf, "reloaded theme", request.path));
+ core.setMessage(.at(request.pane), message.stamp(&msg_buf, "reloaded theme", request.path));
}
return false;
}
@@ -706,7 +706,7 @@ test "a restored file is watched again: one clean takes what its file became sin
defer watchPane(fd, &watches, id, null, pane.serial, .{ .text = 0 });
var armed = false;
while (core.nextEffect()) |effect| switch (effect) {
- .watch => |watch| if (watch.pane == id and watch.on) {
+ .watch => |watch| if (watch.pane.index() == id and watch.on) {
_ = applyEffect(core, io, fd, &watches, id, watch.on, watch.mode);
armed = true;
},
@@ -774,7 +774,7 @@ test "ordinary file watches still reconcile changes between open and watch" {
defer watchPane(fd, &watches, id, null, pane.serial, .{ .text = 0 });
var armed = false;
while (core.nextEffect()) |effect| switch (effect) {
- .watch => |watch| if (watch.pane == id and watch.on) {
+ .watch => |watch| if (watch.pane.index() == id and watch.on) {
try std.testing.expectEqual(.reconcile, watch.mode);
try std.testing.expect(!applyEffect(core, io, fd, &watches, id, watch.on, watch.mode));
armed = true;
@@ -949,7 +949,7 @@ test "a watched file deleted wakes the watch at once, and its pane says so" {
var watches: Table = @splat(null);
defer watchPane(fd, &watches, id, null, pane.serial, .{ .text = 0 });
while (core.nextEffect()) |effect| switch (effect) {
- .watch => |watch| if (watch.pane == id and watch.on) {
+ .watch => |watch| if (watch.pane.index() == id and watch.on) {
_ = applyEffect(core, io, fd, &watches, id, watch.on, watch.mode);
},
else => {},