From 41bbbd05dccb02631ed785d19ed54fb4edfcc471 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Sun, 27 Sep 2026 21:49:28 -0300 Subject: Move colour themes out of pardes.zig into colors.zig Pure move, no behaviour change: the Theme type, the curated palettes, fold and the themes ring with its two comptime checks, themeContrast, mix, ChromeTheme, ChromeAnimation and initial_chrome, the Pardes methods that load theme files and switch themes (nextThemeFileGeneration, requestThemeFile, ThemeFileRequest, themeFileRequest, failThemeFile, loadThemeFile, finishThemeInitialization, invalidateThemeDependentRasters, setThemeIndex), and the ten theme tests go verbatim to colors.zig. The methods become free functions taking `p: *Pardes`; their call sites change from `p.setThemeIndex(i)` to `colors.setThemeIndex(p, i)` (37 of them, in pardes.zig, builtins.zig, file_watch.zig, macos.zig and two test files). pardes.zig keeps `pub const Theme/themes/native_theme_count/ ChromeTheme = colors.X;` for the shells that name them, and sync and enterTagEdit become pub because a moved test calls them. Co-Authored-By: Claude Opus 5.5 --- src/file_watch.zig | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/file_watch.zig') diff --git a/src/file_watch.zig b/src/file_watch.zig index dfcce65f..2d1c0d25 100644 --- a/src/file_watch.zig +++ b/src/file_watch.zig @@ -13,6 +13,7 @@ const builtin = @import("builtin"); const libc = std.c; const linux = std.os.linux; const pardes = @import("pardes.zig"); +const colors = @import("colors.zig"); const filesystem = @import("fs.zig"); const message = pardes.Pardes.Message; @@ -551,13 +552,13 @@ pub fn applyThemeEffect( ) bool { watchPath(fd, watches, theme_slot, null, 0, .{ .text = 0 }); if (!on) return false; - const request = core.themeFileRequest(generation) orelse return false; + const request = colors.themeFileRequest(core, generation) orelse return false; const bytes = filesystem.readFile(gpa, request.path) catch |err| { - core.failThemeFile(generation, err); + colors.failThemeFile(core, generation, err); return false; }; defer gpa.free(bytes); - if (!core.loadThemeFile(generation, bytes, animate)) return false; + if (!colors.loadThemeFile(core, generation, bytes, animate)) return false; const hash = std.hash.Wyhash.hash(0, bytes); watchPath(fd, watches, theme_slot, request.path, generation, .{ .text = hash }); if (watches[theme_slot] == null) return false; @@ -574,7 +575,7 @@ pub fn reloadTheme( announce: bool, ) bool { const watched = watches[theme_slot] orelse return false; - const request = core.themeFileRequest(watched.serial) orelse return false; + const request = colors.themeFileRequest(core, watched.serial) orelse return false; // Same re-arm as reloadPane's, for the same reason: a .zon saved by rename // moves the inode the file filter is on. if (comptime builtin.os.tag == .macos) { @@ -582,7 +583,7 @@ pub fn reloadTheme( } const bytes = filesystem.readFile(gpa, request.path) catch |err| { core.invalidate(); - core.failThemeFile(watched.serial, err); + colors.failThemeFile(core, watched.serial, err); return false; }; defer gpa.free(bytes); @@ -591,7 +592,7 @@ pub fn reloadTheme( .text => |accepted| if (accepted == hash) return false, .pdf => unreachable, } - if (!core.loadThemeFile(watched.serial, bytes, true)) return false; + if (!colors.loadThemeFile(core, watched.serial, bytes, true)) return false; core.invalidate(); const live = if (watches[theme_slot]) |*entry| entry else return false; if (live.serial != watched.serial) return false; @@ -784,7 +785,7 @@ test "theme watch reloads valid ZON and keeps the last theme across a bad save" const core = try pardes.Pardes.init(gpa, .{ .tty_only = true }); defer core.deinit(); while (core.nextEffect()) |_| {} - core.requestThemeFile(0, path); + colors.requestThemeFile(core, 0, path); const request = while (core.nextEffect()) |effect| switch (effect) { .theme_file => |theme_file| break theme_file, else => {}, -- cgit v1.3