6

I use fmt based logger with optionally color prints - which relies on ANSI color commands.

Unfortunately on Windows 10 it is disabled by default. I know how to enable it but I still want to find out how to test whether the console supports ANSI commands or not. Does anybody know?

phuclv
  • 37,963
  • 15
  • 156
  • 475
ALX23z
  • 4,456
  • 1
  • 11
  • 18

1 Answers1

5

On Windows you can get/set the ANSI color support by checking/setting the ENABLE_VIRTUAL_TERMINAL_PROCESSING flag with SetConsoleMode() or GetConsoleMode().

There's also the HKEY_CURRENT_USER\Console\VirtualTerminalLevel registry key for global virtual terminal settings. See also https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

On *nix you can use the following ways

phuclv
  • 37,963
  • 15
  • 156
  • 475