From 82b64b6a7fc99d0c7560ee057d3b1f6021446dc4 Mon Sep 17 00:00:00 2001 From: plyght Date: Mon, 3 Feb 2025 14:59:25 -0500 Subject: [PATCH] add Zenbones dark theme and fix some build issues --- build.zig | 1 + build.zig.zon | 7 ++++++- src/compile.zig | 28 ++++++++++++++++++++++------ src/theme_files.zig | 3 ++- 4 files changed, 31 insertions(+), 8 deletions(-) diff --git a/build.zig b/build.zig index 25b3eb2..ddd6643 100644 --- a/build.zig +++ b/build.zig @@ -84,4 +84,5 @@ fn add_themes(b: *std.Build, exe: anytype) void { theme_file(b, exe, "catppuccin", "themes/macchiato.json"); theme_file(b, exe, "catppuccin", "themes/mocha.json"); theme_file(b, exe, "mellow", "themes/mellow.json"); + theme_file(b, exe, "zenbones", "extras/vscode/themes/zenbones_dark_default.json"); } diff --git a/build.zig.zon b/build.zig.zon index 79193e8..376a592 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -72,10 +72,15 @@ .theme_mellow = .{ .url = "https://github.com/mellow-theme/mellow-theme/archive/00cea86c91a8eb95af09b2cb587a30d52e06ba91.tar.gz", .hash = "122062276c850b37d78f4f981c25c1b14f05d1124429b6e496fe059107c9115d00da", - } + }, + .theme_zenbones = .{ + .url = "https://github.com/rpbritton/zenbones.vscode/archive/97c071875576078395a9dc026ec71a5ff8db68ab.tar.gz", + .hash = "12205871af8254b098b844d684e13eebe038aca0671f18e051ffeadf350c761d6e18" + }, }, .paths = .{ "build.zig", "build.zig.zon", }, } + diff --git a/src/compile.zig b/src/compile.zig index e906ba2..df6aa83 100644 --- a/src/compile.zig +++ b/src/compile.zig @@ -313,14 +313,30 @@ fn find_color(name: []const u8, cb: []const u8) ?Color { } fn find_in_colors(name: []const u8, iter: *[]const u8) ?Color { - var len = cbor.decodeMapHeader(iter) catch unreachable; + var len = cbor.decodeMapHeader(iter) catch return null; while (len > 0) : (len -= 1) { var field_name: []const u8 = undefined; - var value: []const u8 = undefined; - if (!(cbor.matchString(iter, &field_name) catch unreachable)) unreachable; - if (!(cbor.matchString(iter, &value) catch unreachable)) unreachable; - if (eql(u8, field_name, name)) - return parse_color_value(value); + // Try to match field name, skip if not a string + if (cbor.matchString(iter, &field_name) catch false) { + // If we find the field we're looking for + if (eql(u8, field_name, name)) { + var value: []const u8 = undefined; + // Try to match the value as string + if (cbor.matchString(iter, &value) catch false) { + return parse_color_value(value); + } else { + // Skip non-string value + cbor.skipValue(iter) catch return null; + } + } else { + // Skip value for non-matching field + cbor.skipValue(iter) catch return null; + } + } else { + // Skip both non-string field name and its value + cbor.skipValue(iter) catch return null; + cbor.skipValue(iter) catch return null; + } } return null; } diff --git a/src/theme_files.zig b/src/theme_files.zig index 807a203..031ab4e 100644 --- a/src/theme_files.zig +++ b/src/theme_files.zig @@ -46,7 +46,8 @@ pub const theme_files = [_]theme_file{ THEME("themes/macchiato.json"), THEME("themes/mocha.json"), THEME("themes/mellow.json"), - + THEME("extras/vscode/themes/zenbones_dark_default.json"), + // light themes THEME("themes/1984-light-color-theme.json"),