mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Enabled ANSI color support in Windows console for retroshare-service
This commit is contained in:
parent
cd81d69357
commit
eb7e2ec8e6
@ -111,6 +111,33 @@ int main(int argc, char* argv[])
|
||||
signal(SIGBREAK, signalHandler);
|
||||
#endif // ifdef SIGBREAK
|
||||
|
||||
#ifdef WINDOWS_SYS
|
||||
// Enable ANSI color support in Windows console
|
||||
{
|
||||
#ifndef ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||
#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4
|
||||
#endif
|
||||
|
||||
HANDLE hStdin = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
if (hStdin) {
|
||||
DWORD consoleMode;
|
||||
if (GetConsoleMode(hStdin, &consoleMode)) {
|
||||
if ((consoleMode & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0) {
|
||||
if (SetConsoleMode(hStdin, consoleMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING)) {
|
||||
std::cout << "Enabled ANSI color support in console" << std::endl;
|
||||
} else {
|
||||
RsErr() << "Error getting console mode" << std::endl;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RsErr() << "Error getting console mode" << std::endl;
|
||||
}
|
||||
} else {
|
||||
RsErr() << "Error getting stdin handle" << std::endl;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
RsInfo() << "\n" <<
|
||||
"+================================================================+\n"
|
||||
"| o---o o |\n"
|
||||
|
Loading…
Reference in New Issue
Block a user