Cleaned up imports for windows virtual terminal sequences enabling.

pull/159/head
David Pokora 6 years ago
parent 2855b5d992
commit 06736e2214
No known key found for this signature in database
GPG Key ID: 3CED48D1BB21BDD7
  1. 8
      slither/utils/colors.py

@ -25,10 +25,10 @@ def enable_windows_virtual_terminal_sequences():
Reference: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences Reference: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
""" """
import ctypes from ctypes import windll, byref
from ctypes.wintypes import DWORD, HANDLE from ctypes.wintypes import DWORD, HANDLE
kernel32 = ctypes.windll.kernel32 kernel32 = windll.kernel32
virtual_terminal_flag = 0x04 # ENABLE_VIRTUAL_TERMINAL_PROCESSING virtual_terminal_flag = 0x04 # ENABLE_VIRTUAL_TERMINAL_PROCESSING
# Obtain our stdout/stderr handles. # Obtain our stdout/stderr handles.
@ -43,8 +43,8 @@ def enable_windows_virtual_terminal_sequences():
return False return False
# Try to obtain the current flags for the console. # Try to obtain the current flags for the console.
current_mode = ctypes.wintypes.DWORD() current_mode = DWORD()
if not kernel32.GetConsoleMode(current_handle, ctypes.byref(current_mode)): if not kernel32.GetConsoleMode(current_handle, byref(current_mode)):
return False return False
# If the virtual terminal sequence processing is not yet enabled, we enable it. # If the virtual terminal sequence processing is not yet enabled, we enable it.

Loading…
Cancel
Save