summaryrefslogtreecommitdiff
path: root/core/Core.zig
diff options
context:
space:
mode:
Diffstat (limited to 'core/Core.zig')
-rw-r--r--core/Core.zig37
1 files changed, 16 insertions, 21 deletions
diff --git a/core/Core.zig b/core/Core.zig
index e727d27d..947fee4c 100644
--- a/core/Core.zig
+++ b/core/Core.zig
@@ -12,7 +12,6 @@ const BOX_H = pardes.BOX_H;
const Builtin = pardes.Builtin;
const COLBAR_H = pardes.COLBAR_H;
const CellPixels = pardes.CellPixels;
-const ChromeTheme = pardes.ChromeTheme;
const Color = pardes.Color;
const Effect = pardes.Effect;
const Event = pardes.Event;
@@ -47,7 +46,6 @@ const TAG_TEXT_INSET = pardes.TAG_TEXT_INSET;
const TOPBAR_H = pardes.TOPBAR_H;
const TagHit = pardes.TagHit;
const Text = pardes.panes.Text;
-const LegacyTheme = pardes.LegacyTheme;
const builtins = pardes.builtins;
const colors = pardes.colors;
const column_weight_unit = layout.column_weight_unit;
@@ -345,19 +343,19 @@ locations_config: locations.Config = .{},
locations_cache: locations.Cache = .{},
tty_filter_palette: pardes.Term.FilterPalette = .{},
font_request_taken: bool = false,
-custom_theme: ?LegacyTheme = null,
+custom_theme: ?colors.Theme = null,
/// The theme the window wears while a picker of them (or `:theme `)
/// previews one, by index, and its chrome (colors.previewTheme); the
/// session's own theme untouched under it.
theme_preview: ?u16 = null,
-preview_chrome: ChromeTheme = undefined,
+preview_chrome: colors.Chrome = undefined,
theme_file_path: config.Settings.Text(limits.host_path_cap) = .{},
/// The ThemeFile last loaded whole: what /ctl and DumpConfig name, and
/// what a failed ThemeFile goes back to (colors.revertThemeFile).
theme_file_loaded: config.Settings.Text(limits.host_path_cap) = .{},
theme_file_generation: u32 = 0,
theme_file_pane: Pane.Id = .at(0),
-theme_chrome: colors.ChromeTheme = undefined,
+theme_chrome: colors.Chrome = undefined,
/// Every drawn frame's timings (FrameStats: the Debug box, PARDES_FRAMES):
/// its runner's (`Options.frames`), which its frontend writes as it draws
/// and reads input, never the core's memory; a core with no runner (a
@@ -2173,23 +2171,20 @@ fn sizes(p: *const Pardes, pane: *const Pane) bool {
return pane.sized_by == p.live;
}
-/// The theme in the old names, for what still reads a theme's own
-/// fields (colors.ChromeTheme.view).
-pub fn theme(p: *const Pardes) *const LegacyTheme {
- if (p.theme_preview == null) if (p.custom_theme) |*custom| return custom;
- return &p.chromeTheme().view;
-}
-
-/// The colours of the chrome: the theme's, set as it changes.
-pub fn chromeTheme(p: *const Pardes) *const ChromeTheme {
- if (p.theme_preview != null) return &p.preview_chrome;
- return &p.theme_chrome;
+/// The theme the window wears: one a picker previews, a theme file's, or
+/// the session's. Its name is what is read of it; a surface draws its
+/// chrome (`chrome`).
+pub fn theme(p: *const Pardes) *const colors.Theme {
+ if (p.theme_preview) |i| return &colors.themes[i];
+ if (p.custom_theme) |*custom| return custom;
+ return &colors.themes[p.settings.theme];
}
/// Every colour a surface draws (colors.Chrome), the theme's or the one a
/// picker previews: worked out as the theme changes, never a frame.
pub fn chrome(p: *const Pardes) *const colors.Chrome {
- return &p.chromeTheme().resolved;
+ if (p.theme_preview != null) return &p.preview_chrome;
+ return &p.theme_chrome;
}
/// When the core next needs a frame, on the `stepped_ns` timeline: a
@@ -2544,7 +2539,7 @@ test "startup config runs builtin lines in order and isolates bad lines" {
try std.testing.expectEqualStrings("acme", p.theme().name);
// The theme lands without a tween (the chrome is the theme's at once);
// the bad lines are said, so a notice may be up.
- try std.testing.expectEqual(ChromeTheme.fromTheme(p.theme()), p.chromeTheme().*);
+ try std.testing.expectEqual(colors.Chrome.of(p.theme()), p.chrome().*);
try std.testing.expect(!p.quit);
for (0..p.effects_len) |i| switch (p.effects[(p.effects_head + i) % p.effects.len]) {
.write => |w| {
@@ -3649,8 +3644,8 @@ test "startup config overrides restored styling before initFromDump returns" {
try std.testing.expectEqualStrings("acme", restored.theme().name);
try std.testing.expect(!source.animationActive());
try std.testing.expect(!restored.animationActive());
- try std.testing.expectEqual(ChromeTheme.fromTheme(source.theme()), source.chromeTheme().*);
- try std.testing.expectEqual(ChromeTheme.fromTheme(restored.theme()), restored.chromeTheme().*);
+ try std.testing.expectEqual(colors.Chrome.of(source.theme()), source.chrome().*);
+ try std.testing.expectEqual(colors.Chrome.of(restored.theme()), restored.chrome().*);
}
test "restored terminals keep monotonic nonzero pane identities" {
@@ -3743,7 +3738,7 @@ test "tabbed file aligns syntax cursor and mouse at the nearest insertion gap" {
const text_x = rect.x + config.GUTTER + config.PREFIX_W;
const body_y = rect.y + BOX_H;
// The keyword's ink shows the glyph boundaries.
- const kw: Color = .{ .rgb = p.theme().kw };
+ const kw: Color = .{ .rgb = p.theme().keyword };
for (0..config.tab_width) |col|
try std.testing.expect(!std.meta.eql(kw, surface.at(text_x + @as(u16, @intCast(col)), body_y).style.fg));
for (0.."return".len) |col|