Ensure having set_console implies having default_console_text_attributes

This commit is contained in:
Kovid Goyal 2017-05-10 22:47:53 +05:30
parent 3883efff05
commit 41aadb096c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -127,6 +127,7 @@ class Detect(object):
if f(self.file_handle, byref(mode)):
# Stream is a console
self.set_console = windll.kernel32.SetConsoleTextAttribute
self.default_console_text_attributes = WCOLORS['white']
kernel32 = WinDLL(b'kernel32', use_last_error=True)
self.write_console = kernel32.WriteConsoleW
self.write_console.argtypes = [wintypes.HANDLE, wintypes.c_wchar_p, wintypes.DWORD, POINTER(wintypes.DWORD), wintypes.LPVOID]
@ -134,7 +135,6 @@ class Detect(object):
kernel32.GetConsoleScreenBufferInfo.argtypes = [wintypes.HANDLE, ctypes.POINTER(CONSOLE_SCREEN_BUFFER_INFO)]
kernel32.GetConsoleScreenBufferInfo.restype = wintypes.BOOL
csbi = CONSOLE_SCREEN_BUFFER_INFO()
self.default_console_text_attributes = WCOLORS['white']
if kernel32.GetConsoleScreenBufferInfo(self.file_handle, byref(csbi)):
self.default_console_text_attributes = csbi.wAttributes
self.is_console = True