Metrics UI: Enable virtual terminal sequence processing on Windows
https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
This commit is contained in:
parent
c5b26acad8
commit
8fa09c244a
|
@ -414,6 +414,30 @@ int printInitMessage()
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
|
||||||
|
|
||||||
|
bool enableVTMode()
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void ThreadShowMetricsScreen()
|
void ThreadShowMetricsScreen()
|
||||||
{
|
{
|
||||||
// Make this thread recognisable as the metrics screen thread
|
// Make this thread recognisable as the metrics screen thread
|
||||||
|
@ -425,6 +449,10 @@ void ThreadShowMetricsScreen()
|
||||||
int64_t nRefresh = GetArg("-metricsrefreshtime", isTTY ? 1 : 600);
|
int64_t nRefresh = GetArg("-metricsrefreshtime", isTTY ? 1 : 600);
|
||||||
|
|
||||||
if (isScreen) {
|
if (isScreen) {
|
||||||
|
#ifdef WIN32
|
||||||
|
enableVTMode();
|
||||||
|
#endif
|
||||||
|
|
||||||
// Clear screen
|
// Clear screen
|
||||||
std::cout << "\e[2J";
|
std::cout << "\e[2J";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue