From 93b7eac6570f38e1d0d25da893e184ecbbe05fdf Mon Sep 17 00:00:00 2001 From: Stefan Boberg Date: Tue, 16 May 2023 13:33:16 +0200 Subject: Moved EnableVTMode function into zencore (#311) --- src/zencore/logging.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'src/zencore/logging.cpp') diff --git a/src/zencore/logging.cpp b/src/zencore/logging.cpp index 33e81825c..07b379cba 100644 --- a/src/zencore/logging.cpp +++ b/src/zencore/logging.cpp @@ -85,6 +85,33 @@ ShutdownLogging() spdlog::shutdown(); } +bool +EnableVTMode() +{ +#if ZEN_PLATFORM_WINDOWS + // Set output mode to handle virtual terminal sequences + HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE); + if (hOut == INVALID_HANDLE_VALUE) + { + return false; + } + + DWORD dwMode = 0; + if (!GetConsoleMode(hOut, &dwMode)) + { + return false; + } + + dwMode |= ENABLE_VIRTUAL_TERMINAL_PROCESSING; + if (!SetConsoleMode(hOut, dwMode)) + { + return false; + } +#endif + + return true; +} + } // namespace zen::logging namespace zen { -- cgit v1.2.3