31 const DWORD INVALID_MODE = 0xffffffff;
34 DWORD dwOriginalOutMode;
38 : dwOriginalOutMode(INVALID_MODE)
41 hOut = ::GetStdHandle(STD_OUTPUT_HANDLE);
42 if (hOut != INVALID_HANDLE_VALUE)
44 if (!::GetConsoleMode(hOut, &dwOriginalOutMode))
46 dwOriginalOutMode = INVALID_MODE;
47 std::cout <<
"Failed to get the Console output's original mode." << std::endl;
52 DWORD dwOutMode = dwOriginalOutMode | dwRequestedOutModes;
53 if (!SetConsoleMode(hOut, dwOutMode))
55 std::cout <<
"Failed to enable the Console output's virtual terminal mode." << std::endl;
61 std::cout <<
"Failed to get the Console's output handle." << std::endl;
67 if (dwOriginalOutMode != INVALID_MODE)
69 ::SetConsoleMode(hOut, dwOriginalOutMode);
def EnableVTMode(callable function)
Wrap the given function with enabling and disabling the virtual terminal processing for a Windows Con...
int ENABLE_VIRTUAL_TERMINAL_PROCESSING
Flag that, when set, enables virtual terminal processing and thus support for ANSI escape code handli...
int INVALID_HANDLE_VALUE
Windows indicator of an invalid handle.
The namespace containing all the "helper" functions in the C++ code.
void enableVTMode()
On Windows, enable the virtual terminal processing mode on the Console's output handle....