From 9b42930f61017b8403ff76d827c1c82c0679e327 Mon Sep 17 00:00:00 2001 From: Beyley Thomas Date: Fri, 19 Jan 2024 17:49:29 -0800 Subject: [PATCH] Revert "Try to terminal translation on Windows" This reverts commit ca7593b2a7ab1e712636304bc9a00b55c2672ef9. --- src/main.zig | 14 +------------- src/windows.zig | 17 ----------------- 2 files changed, 1 insertion(+), 30 deletions(-) delete mode 100644 src/windows.zig diff --git a/src/main.zig b/src/main.zig index 3475358..947736d 100644 --- a/src/main.zig +++ b/src/main.zig @@ -7,8 +7,6 @@ const Api = @import("api"); const c = @import("c.zig").c; const Config = @import("config.zig"); -var terminal_translation = true; - pub const std_options = struct { pub fn logFn( comptime message_level: std.log.Level, @@ -24,7 +22,6 @@ pub const std_options = struct { .debug => "[1;35m", .info => "[1;37m", }; - const level_txt = comptime message_level.asText(); const prefix2 = if (scope == .default) ": " else "(" ++ @tagName(scope) ++ "): "; const stderr = std.io.getStdErr().writer(); @@ -32,21 +29,13 @@ pub const std_options = struct { std.debug.getStderrMutex().lock(); defer std.debug.getStderrMutex().unlock(); - if (terminal_translation) { - nosuspend stderr.print("{c}" ++ color ++ level_txt ++ prefix2 ++ format ++ "{c}[0m\n", .{esc_code} ++ args ++ .{esc_code}) catch return; - } else { - nosuspend stderr.print(level_txt ++ prefix2 ++ format, args) catch return; - } + nosuspend stderr.print("{c}" ++ color ++ level_txt ++ prefix2 ++ format ++ "{c}[0m\n", .{esc_code} ++ args ++ .{esc_code}) catch return; } pub const log_level = if (builtin.mode == .Debug) .debug else .info; }; pub fn main() !void { - if (builtin.os.tag == .windows) { - terminal_translation = try @import("windows.zig").enableTerminalSequences(); - } - var gpa = std.heap.GeneralPurposeAllocator(.{}){}; defer if (gpa.deinit() == .leak) @panic("MEMORY LEAK"); const allocator = gpa.allocator(); @@ -395,7 +384,6 @@ pub fn runApp(allocator: std.mem.Allocator) !void { } if (config.close_upon_game_exit) { - std.log.info("User is not in a room, exiting...", .{}); return; } diff --git a/src/windows.zig b/src/windows.zig deleted file mode 100644 index 9b1a568..0000000 --- a/src/windows.zig +++ /dev/null @@ -1,17 +0,0 @@ -const c = @cImport({ - @cDefine("WIN32_LEAN_AND_MEAN", "1"); - @cInclude("windows.h"); -}); - -pub fn enableTerminalSequences() !bool { - const output_handle = c.GetStdHandle(c.STD_OUTPUT_HANDLE); - if (output_handle == c.INVALID_HANDLE_VALUE) { - return error.UnableToGetStdOutHandle; - } - - if (c.SetConsoleMode(output_handle, c.ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0) { - return false; - } - - return true; -}