aboutsummaryrefslogtreecommitdiff
path: root/src/zencore/logging.cpp
diff options
context:
space:
mode:
authorStefan Boberg <[email protected]>2023-05-16 13:33:16 +0200
committerGitHub <[email protected]>2023-05-16 13:33:16 +0200
commit93b7eac6570f38e1d0d25da893e184ecbbe05fdf (patch)
tree87c05d944b32871d6a0a326ccf59373c5afe3d18 /src/zencore/logging.cpp
parentAdd `--gc-projectstore-duration-seconds` option (#281) (diff)
downloadzen-93b7eac6570f38e1d0d25da893e184ecbbe05fdf.tar.xz
zen-93b7eac6570f38e1d0d25da893e184ecbbe05fdf.zip
Moved EnableVTMode function into zencore (#311)
Diffstat (limited to 'src/zencore/logging.cpp')
-rw-r--r--src/zencore/logging.cpp27
1 files changed, 27 insertions, 0 deletions
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 {