feat: support adding entirely new themes via the config

This commit is contained in:
CJ van den Berg 2026-03-31 20:58:00 +02:00
parent d53d155c6d
commit 310221bb26
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9
5 changed files with 126 additions and 71 deletions

View file

@ -895,15 +895,15 @@ pub fn write_theme(theme_name: []const u8, content: []const u8) !void {
pub fn list_themes(allocator: std.mem.Allocator) ![]const []const u8 {
var dir = try std.fs.openDirAbsolute(try get_theme_directory(), .{ .iterate = true });
defer dir.close();
var result = std.ArrayList([]const u8).init(allocator);
var result: std.ArrayList([]const u8) = .empty;
var iter = dir.iterateAssumeFirstIteration();
while (try iter.next()) |entry| {
switch (entry.kind) {
.file, .sym_link => try result.append(try allocator.dupe(u8, std.fs.path.stem(entry.name))),
.file, .sym_link => try result.append(allocator, try allocator.dupe(u8, std.fs.path.stem(entry.name))),
else => continue,
}
}
return result.toOwnedSlice();
return result.toOwnedSlice(allocator);
}
pub fn get_config_dir() ConfigDirError![]const u8 {