From 2fd38506b2ff92f511fbb16372f6a62588d86799 Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 24 Jul 2021 01:13:23 -0700 Subject: [PATCH] add marlersoft/zigwin32 to enable ansi escape codes on windows terminals --- deps.zig | 8 +++++++- src/main.zig | 6 ++++++ zig.mod | 1 + zigmod.lock | 1 + zigmod.sum | 1 + 5 files changed, 16 insertions(+), 1 deletion(-) diff --git a/deps.zig b/deps.zig index 00a71652128cdb26e3bcade16d5cafb78d400528..26507a38c62775d0cba8a2b158896dddc5becd78 100644 --- a/deps.zig +++ b/deps.zig @@ -53,6 +53,7 @@ const dirs = struct { pub const _u9w9dpp6p804 = cache ++ "/git/github.com/MasterQ32/zig-uri"; pub const _ocmr9rtohgcc = cache ++ "/git/github.com/nektro/zig-json"; pub const _tnj3qf44tpeq = cache ++ "/git/github.com/nektro/zig-range"; + pub const _o6ogpor87xc2 = cache ++ "/git/github.com/marlersoft/zigwin32"; }; pub const package_data = struct { @@ -113,9 +114,14 @@ pub const package_data = struct { .pkg = Pkg{ .name = "range", .path = .{ .path = dirs._tnj3qf44tpeq ++ "/src/lib.zig" }, .dependencies = null }, }; + pub const _o6ogpor87xc2 = Package{ + .directory = dirs._o6ogpor87xc2, + .pkg = Pkg{ .name = "win32", .path = .{ .path = dirs._o6ogpor87xc2 ++ "/win32.zig" }, .dependencies = null }, + }; + pub const _89ujp8gq842x = Package{ .directory = dirs._89ujp8gq842x, - .pkg = Pkg{ .name = "zigmod", .path = .{ .path = dirs._89ujp8gq842x ++ "/src/lib.zig" }, .dependencies = &.{ _s84v9o48ucb0.pkg.?, _2ta738wrqbaq.pkg.?, _0npcrzfdlrvk.pkg.?, _ejw82j2ipa0e.pkg.?, _ocmr9rtohgcc.pkg.?, _tnj3qf44tpeq.pkg.? } }, + .pkg = Pkg{ .name = "zigmod", .path = .{ .path = dirs._89ujp8gq842x ++ "/src/lib.zig" }, .dependencies = &.{ _s84v9o48ucb0.pkg.?, _2ta738wrqbaq.pkg.?, _0npcrzfdlrvk.pkg.?, _ejw82j2ipa0e.pkg.?, _ocmr9rtohgcc.pkg.?, _tnj3qf44tpeq.pkg.?, _o6ogpor87xc2.pkg.? } }, }; pub const _root = Package{ diff --git a/src/main.zig b/src/main.zig index 011d7f667f2c68226a82698820e6f8725f11fa55..cc620217fc347aeff5796d8cd8170c61a2cc6f49 100644 --- a/src/main.zig +++ b/src/main.zig @@ -3,6 +3,7 @@ const builtin = std.builtin; pub const build_options = @import("build_options"); const zigmod = @import("zigmod"); +const win32 = @import("win32"); pub const u = @import("./util/index.zig"); pub const common = @import("./common.zig"); @@ -33,6 +34,11 @@ pub fn main() !void { return; } + if (builtin.os.tag == .windows) { + const console = win32.system.console; + console.SetConsoleMode(std.io.getStdOut().handle, console.ENABLE_VIRTUAL_TERMINAL_PROCESSING); + } + inline for (std.meta.declarations(available)) |decl| { if (std.mem.eql(u8, args[0], decl.name)) { const cmd = @field(available, decl.name); diff --git a/zig.mod b/zig.mod index d831113569c1dd9e6596809749f9f4407dd85636..066027f6a4fe31e9378d1e4137eca4a6c0217cc3 100644 --- a/zig.mod +++ b/zig.mod @@ -35,3 +35,4 @@ dependencies: - src: git https://github.com/truemedian/zfetch - src: git https://github.com/nektro/zig-json - src: git https://github.com/nektro/zig-range + - src: git https://github.com/marlersoft/zigwin32 diff --git a/zigmod.lock b/zigmod.lock index 834ce23507f4413c6255063ce99f26dc90745e76..f2af4d9589fe10aac394db0933a00e9bea61fbde 100644 --- a/zigmod.lock +++ b/zigmod.lock @@ -10,3 +10,4 @@ git https://github.com/MasterQ32/zig-network commit-b9c91769d8ebd626c8e45b2abb05 git https://github.com/MasterQ32/zig-uri commit-52cdd2061bec0579519f0d30280597f3a1db8b75 git https://github.com/nektro/zig-json commit-72e555fbc0776f2600aee19b01e5ab1855ebec7a git https://github.com/nektro/zig-range commit-890ca308fe09b3d5c866d5cfb3b3d7a95dbf939f +git https://github.com/marlersoft/zigwin32 commit-ca6b8e5c378e31655fa11b886b44b62f703ef090 diff --git a/zigmod.sum b/zigmod.sum index 08f84236e26697c43da0f6d900beb6162e31f511..8bf2773baa5359f1765e61955859d4283089144b 100644 --- a/zigmod.sum +++ b/zigmod.sum @@ -9,3 +9,4 @@ blake3-21f91e48333ac0ca7f4704c96352831c25216e7056d02ce24de95d03fc942246 git/gith blake3-030ebb03f1ed21122e681b06786bea6f2f1b810e8eb9f2029d0eee4f4fb3103f git/github.com/MasterQ32/zig-uri blake3-1893709ffc6359c5f9cd2f9409abccf78a94ed37bb2c6dd075c603356d17c94b git/github.com/nektro/zig-json blake3-09698753782139ab4877d08f33235170836f68b73e482b65cdee5637a6addf86 git/github.com/nektro/zig-range +blake3-949c3cd2c9e834190feeecb010c59ab5047fa721cfbdf67e0f0fd847194a6dad git/github.com/marlersoft/zigwin32 -- 2.54.0