diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-25 00:46:11 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-25 00:46:11 -0300 |
| commit | ac450e5868f528b312abb2b46191cd8bce5bff3d (patch) | |
| tree | efec7b3d6af74f52f8e75a1b0f78ae75de330ab9 /core/colors.zig | |
| parent | 0919fcef12f973d3129b32f79a331ff8e45cb7ac (diff) | |
| download | pardes-ac450e5868f528b312abb2b46191cd8bce5bff3d.tar.gz pardes-ac450e5868f528b312abb2b46191cd8bce5bff3d.zip | |
Command: once a `:` command takes its argument the rows are what it takes, the rest of the line the query, and `:theme ` dresses the whole window in the current row (walk UI, pick-ui SPEC.md §8, item 2 of line E2): `theme ` lists every theme (colors.themes, in the ring's order, `in use` beside the session's), `set ` and `toggle ` the settings this frontend has with their values now (the root ctl's text, ninep/ctl.zig settingsText), `set Wrap ` that setting's words (Settings.choices: `on off`, `walk new-pane`, `off cat frog`; `now` beside the one it has), `open ` the recent files (recent.zig, 200 at most, from the pane's directory, `open` beside a file a pane shows: the directory walk is the pickers' and not in this tree), `pipe ` the pipe history, newest first; filtered as the names are (Names.match, in their order), counted (`273 themes · the window wears the current one`, `2 values`, `1 recent file`), Tab and S-Tab writing the row after the command (`set Wrap off`); THE PREVIEW: colors.wear(p, index) is the one function a state that previews themes calls (agent F's Themes picker can call it as it is): the live view's TagState.worn (an index of colors.themes, in the digest and the dump, held to the themes on a load: replica `.index` isTheme) and every pane flagged previewing, so none dims; Core.theme() returns the worn theme and chromeTheme() its chrome, worked out once a theme (Pardes.worn_chrome, a cache kept out as body_chrome is, made by wear and by a frame's first step for a view that wears another), nothing loaded or set: every pane, tag and band recolours on the next frame; TagState.toRest takes it off, so Esc puts the window's own back, and Enter runs `Theme <the one worn>`; a load meanwhile works out the session's own chrome (colors.finishThemeInitialization no longer reads theme()); TagState.max_hits is at least the themes' count (273: 70 of pardes's, 203 generated) so their rows fit; test/perf.zig --search measures a key in `:` and Tab in `:theme ` with their frames; TEST FIRST: Command.zig ":theme lists the themes and the whole window wears the current one, none dimmed; Tab steps it on, Esc puts the window's own back, Enter keeps the one worn; :set lists the settings with their values, then a setting's values; :pipe the pipes typed last; :open the recent files"; item 1's test reads the theme worn for `:theme acme`; core-test 1022/1189 (167 skipped)
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'core/colors.zig')
| -rw-r--r-- | core/colors.zig | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/core/colors.zig b/core/colors.zig index 84595a30..f0b01c71 100644 --- a/core/colors.zig +++ b/core/colors.zig @@ -764,7 +764,8 @@ pub fn loadThemeFile(p: *Pardes, generation: u32, bytes: []const u8) bool { } pub fn finishThemeInitialization(p: *Pardes) void { - p.chrome = ChromeTheme.fromTheme(p.theme()); + // The session's own theme's: never one a view wears (`wear`). + p.chrome = ChromeTheme.fromTheme(if (p.custom_theme) |*custom| custom else &themes[p.settings.theme]); } /// Themes near `name`, a line of them, for a Theme given a name there is @@ -832,6 +833,26 @@ pub fn themeIndex(name: []const u8) ?usize { return null; } +/// The live view wears theme `index` while a state previews themes (`:theme +/// `, a Themes picker): the whole window drawn in it, no pane dimmed; null, +/// its own again. Nothing is loaded or set: `theme()` and `chromeTheme()` +/// read what the view wears, and rest (TagState.toRest) takes it off. +pub fn wear(p: *Pardes, index: ?usize) void { + const s = &p.view().tag_state; + s.worn = if (index) |i| (if (i < themes.len) @intCast(i) else null) else null; + s.previewing = if (s.worn != null) .full else .empty; + wornChrome(p); +} + +/// The chrome of the theme the live view wears, worked out once a theme +/// (its contrast searches take pow calls): `wear`'s, and a frame's first +/// step's, for a view that wears another than the last one worked out. +pub fn wornChrome(p: *Pardes) void { + const i = p.view().tag_state.worn orelse return; + if (p.worn_chrome) |w| if (w.index == i) return; + p.worn_chrome = .{ .index = i, .chrome = ChromeTheme.fromTheme(&themes[i]) }; +} + pub fn setThemeIndex(p: *Pardes, index: usize) void { if (index >= themes.len or (p.custom_theme == null and p.theme_file_path.get().len == 0 and |
