diff options
| author | Gabriel Schneider <[email protected]> | 2026-08-18 14:21:38 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-08-18 23:45:30 -0300 |
| commit | 382abe3dafb872b3e6c9792a9cc0abcf6267e180 (patch) | |
| tree | e30f47d911561db9b02e714287a1658822c77a09 /src/tty/tty.zig | |
| parent | c24a9e40215bc30c68c9db7675f1c6a07d9bbae3 (diff) | |
| download | pardes-382abe3dafb872b3e6c9792a9cc0abcf6267e180.tar.gz pardes-382abe3dafb872b3e6c9792a9cc0abcf6267e180.zip | |
file_watch + builtins + config: richer watch semantics, new builtins, config docs
Diffstat (limited to 'src/tty/tty.zig')
| -rw-r--r-- | src/tty/tty.zig | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/tty/tty.zig b/src/tty/tty.zig index 05585f46..a0159f46 100644 --- a/src/tty/tty.zig +++ b/src/tty/tty.zig @@ -15,6 +15,7 @@ const temp_file = @import("../temp_file.zig"); const shell_bin = @import("../shell_bin.zig"); const message = @import("../message.zig"); const file_watch = @import("../file_watch.zig"); +const user_config = @import("../user_config.zig"); const selection_pipe = @import("../selection_pipe.zig"); const nested = @import("../nested.zig"); const panel_compositor = @import("panel_compositor.zig"); @@ -342,7 +343,7 @@ test "Linux host watch closes initial race and reloads rename-over PDF while idl if (fd < 0) return error.InotifyInitFailed; defer _ = libc.close(fd); var watches: file_watch.Table = @splat(null); - defer for (0..watches.len) |id| file_watch.watchPane( + defer for (0..pardes.MAX_PANES) |id| file_watch.watchPane( fd, &watches, @intCast(id), @@ -854,7 +855,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options) !void { // the replay core's pane ids mean new things, and the dying core's // `watch off` effects go into a queue nobody drains — drop the lot // here. The new core emits its own `on`s as it builds its panes. - for (0..watches.len) |wid| file_watch.watchPane( + for (0..pardes.MAX_PANES) |wid| file_watch.watchPane( inotify_fd, &watches, @intCast(wid), @@ -862,6 +863,7 @@ pub fn run(init: std.process.Init, opts: pardes.Options) !void { 0, .{ .text = 0 }, ); + _ = file_watch.applyThemeEffect(core, gpa, inotify_fd, &watches, 0, false, false); var image_iterator = kitty_handles.valueIterator(); while (image_iterator.next()) |handle| vx.freeImage(tty.writer(), handle.id); kitty_handles.clearRetainingCapacity(); @@ -1122,6 +1124,16 @@ fn drainEffects( _ = libc.close(fd); core.setLastDump(path); }, + .dump_themes => |request| { + const config_dir = core.opts.config_dir orelse continue; + const out_dir = user_config.dumpThemes(io, gpa, config_dir, pardes.themes) catch |err| { + core.reportError(request.pane, "dump themes", err); + continue; + }; + defer gpa.free(out_dir); + var mbuf: [256]u8 = undefined; + core.setMessage(request.pane, message.stamp(&mbuf, "dumped themes", out_dir)); + }, .set_clipboard => { // mirror the core's yank register out via OSC 52 if (core.yank) |y| vx.copyToSystemClipboard(tty.writer(), y, gpa) catch {}; @@ -1206,6 +1218,17 @@ fn drainEffects( if (file_watch.applyEffect(core, io, gpa, inotify_fd, watches, w.pane, w.on)) loop.postEvent(.files_changed) catch {}; }, + .theme_file => |request| { + if (file_watch.applyThemeEffect( + core, + gpa, + inotify_fd, + watches, + request.generation, + request.on, + threads_ok, + )) loop.postEvent(.files_changed) catch {}; + }, .quit => {}, }; } |
