Skip to content

Commit

Permalink
Disable colors on Windows
Browse files Browse the repository at this point in the history
Too many unknowns trying to make this work reliably on Windows so just
disabling now to declutter output, we can re-enable later and do it
properly.
  • Loading branch information
bobf committed Apr 3, 2024
1 parent 36fc391 commit 336b80e
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions src/jetzig/colors.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const std = @import("std");

const builtin = @import("builtin");

const types = @import("types.zig");

const codes = .{
Expand All @@ -16,15 +18,23 @@ const codes = .{
};

fn wrap(comptime attribute: []const u8, comptime message: []const u8) []const u8 {
return codes.escape ++ attribute ++ "m" ++ message ++ codes.escape ++ codes.reset ++ "m";
if (builtin.os.tag == .windows) {
return message;
} else {
return codes.escape ++ attribute ++ "m" ++ message ++ codes.escape ++ codes.reset ++ "m";
}
}

fn runtimeWrap(allocator: std.mem.Allocator, attribute: []const u8, message: []const u8) ![]const u8 {
return try std.mem.join(
allocator,
"",
&[_][]const u8{ codes.escape, attribute, "m", message, codes.escape, codes.reset, "m" },
);
if (builtin.os.tag == .windows) {
return try allocator.dupe(u8, message);
} else {
return try std.mem.join(
allocator,
"",
&[_][]const u8{ codes.escape, attribute, "m", message, codes.escape, codes.reset, "m" },
);
}
}

pub fn black(comptime message: []const u8) []const u8 {
Expand Down

0 comments on commit 336b80e

Please sign in to comment.