18STD_OUTPUT_HANDLE = -11
21ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x0004
25originalConsoleMode =
None
31 kernel32 = ctypes.windll.kernel32
41 global originalConsoleMode
42 stdOutput = kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
43 oldMode = ctypes.c_uint32(0)
44 if kernel32.GetConsoleMode(stdOutput, ctypes.byref(oldMode)):
45 originalConsoleMode = oldMode.value
46 newMode = originalConsoleMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING
47 kernel32.SetConsoleMode(stdOutput, newMode)
53 if kernel32
and originalConsoleMode
is not None:
54 stdOutput = kernel32.GetStdHandle(STD_OUTPUT_HANDLE)
55 kernel32.SetConsoleMode(stdOutput, originalConsoleMode)
66def EnableVTMode(function : callable):
None _SetVTMode()
If we are on Windows (as indicated by the presence of the Kernel32 DLL), set the virtual terminal pro...
None _RestoreVTMode()
If we are on Windows (as indicated by the presence of the Kernel32 DLL), restore the standard output ...