refactor: get zine watcher to build in flow

This commit is contained in:
CJ van den Berg 2025-11-30 15:03:14 +01:00
parent db4e3e1936
commit b698fffd25
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
7 changed files with 90 additions and 30 deletions

View file

@ -241,3 +241,22 @@ pub fn buffer_from_ref(self: *Self, buffer_ref: usize) ?*Buffer {
pub fn buffer_to_ref(_: *Self, buffer: *Buffer) usize {
return @intFromPtr(buffer);
}
const watcher = @import("watcher");
pub fn watch_all_buffers(self: *Self) watcher.Error!void {
var debouncer: watcher.Debouncer = .{};
var buffers: std.ArrayList([]const u8) = .empty;
var iter = self.buffers.keyIterator();
while (iter.next()) |key| {
(try buffers.addOne(self.allocator)).* = key.*;
}
var watcher_: watcher.Watcher = try .init(
self.allocator,
&debouncer,
&.{}, // dirs_to_watch.items,
);
try watcher_.start();
}