As of Windows 10, the Windows console supports (some) ANSI escape
    sequences, but it needs to be enabled using `SetConsoleMode` first.

    More info on the escape sequences supported:
    https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx

def enable_virtual_terminal_processing():
    """As of Windows 10, the Windows console supports (some) ANSI escape
    sequences, but it needs to be enabled using `SetConsoleMode` first.

    More info on the escape sequences supported:
    https://msdn.microsoft.com/en-us/library/windows/desktop/mt638032(v=vs.85).aspx
    """
    stdout = GetStdHandle(STD_OUTPUT_HANDLE)
    flags = GetConsoleMode(stdout)
    SetConsoleMode(stdout, flags | ENABLE_VIRTUAL_TERMINAL_PROCESSING)