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/macos.zig | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'src/macos.zig') diff --git a/src/macos.zig b/src/macos.zig index b19c5996..402b3c12 100644 --- a/src/macos.zig +++ b/src/macos.zig @@ -6,6 +6,7 @@ const builtin = @import("builtin"); const posix = std.posix; const libc = std.c; const pardes = @import("pardes.zig"); +const colors = @import("colors.zig"); const look = @import("look.zig"); const message = pardes.Pardes.Message; const layout = @import("layout.zig"); @@ -1133,13 +1134,13 @@ fn setThemeFileWatch(st: *State, request_generation: u32, on: bool, animate: boo const stopped = st.file_watches.stop(st.gpa, theme_watch_pane); hostWatchFile(theme_watch_pane, stopped, null, 0); if (!on) return; - const request = st.core.themeFileRequest(request_generation) orelse return; + const request = colors.themeFileRequest(st.core, request_generation) orelse return; const bytes = filesystem.readFile(st.gpa, request.path) catch |err| { - st.core.failThemeFile(request_generation, err); + colors.failThemeFile(st.core, request_generation, err); return; }; defer st.gpa.free(bytes); - if (!st.core.loadThemeFile(request_generation, bytes, animate)) return; + if (!colors.loadThemeFile(st.core, request_generation, bytes, animate)) return; const callback_generation = st.file_watches.replace( st.gpa, theme_watch_pane, @@ -1154,10 +1155,10 @@ fn setThemeFileWatch(st: *State, request_generation: u32, on: bool, animate: boo fn reloadWatchedTheme(st: *State, announce: bool) bool { const watched = if (st.file_watches.entries[theme_watch_pane]) |*entry| entry else return false; - const request = st.core.themeFileRequest(watched.serial) orelse return false; + const request = colors.themeFileRequest(st.core, watched.serial) orelse return false; if (!std.mem.eql(u8, watched.path, request.path)) return false; const bytes = filesystem.readFile(st.gpa, watched.path) catch |err| { - st.core.failThemeFile(watched.serial, err); + colors.failThemeFile(st.core, watched.serial, err); return false; }; defer st.gpa.free(bytes); @@ -1166,7 +1167,7 @@ fn reloadWatchedTheme(st: *State, announce: bool) bool { .text => |accepted| if (accepted == hash) return false, .pdf => unreachable, } - if (!st.core.loadThemeFile(watched.serial, bytes, true)) return false; + if (!colors.loadThemeFile(st.core, watched.serial, bytes, true)) return false; const live = if (st.file_watches.entries[theme_watch_pane]) |*entry| entry else return false; if (live.serial != watched.serial) return false; live.generation_on_disk = .{ .text = hash }; -- cgit v1.3