File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed
Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 88#include " util/java.h"
99
1010#ifdef _WIN32
11- #include " util/os.h" // set_console_cp_utf8
11+ #include " util/os.h"
1212#endif
1313
1414using namespace allay_launcher ;
@@ -107,6 +107,8 @@ auto parse_arguments(int argc, char* argv[]) {
107107int main (int argc, char * argv[]) try {
108108#ifdef _WIN32
109109 util::os::set_console_cp_utf8 ();
110+ // Make it able to use of ANSI escape codes in the console
111+ util::os::enable_virtual_terminal_processing ();
110112#endif
111113
112114 setup_logger ();
Original file line number Diff line number Diff line change @@ -18,6 +18,8 @@ bool is_legacy_windows();
1818
1919#ifdef _WIN32
2020void set_console_cp_utf8 ();
21+
22+ void enable_virtual_terminal_processing ();
2123#endif
2224
2325} // namespace allay_launcher::util::os
Original file line number Diff line number Diff line change @@ -31,4 +31,17 @@ void set_console_cp_utf8() {
3131
3232bool is_legacy_windows () { return !IsWindows10OrGreater (); }
3333
34+ void enable_virtual_terminal_processing () {
35+ HANDLE hOut = GetStdHandle (STD_OUTPUT_HANDLE);
36+ if (hOut == INVALID_HANDLE_VALUE) {
37+ return ;
38+ }
39+
40+ DWORD dwMode = 0 ;
41+ if (!GetConsoleMode (hOut, &dwMode)) {
42+ return ;
43+ }
44+
45+ SetConsoleMode (hOut, dwMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING);
46+ }
3447} // namespace allay_launcher::util::os
You can’t perform that action at this time.
0 commit comments