Show More
@@ -131,6 +131,7 b' class _CONSOLE_SCREEN_BUFFER_INFO(ctypes' | |||||
131 | ('srWindow', _SMALL_RECT), |
|
131 | ('srWindow', _SMALL_RECT), | |
132 | ('dwMaximumWindowSize', _COORD)] |
|
132 | ('dwMaximumWindowSize', _COORD)] | |
133 |
|
133 | |||
|
134 | _STD_OUTPUT_HANDLE = _DWORD(-11).value | |||
134 | _STD_ERROR_HANDLE = _DWORD(-12).value |
|
135 | _STD_ERROR_HANDLE = _DWORD(-12).value | |
135 |
|
136 | |||
136 | # CreateToolhelp32Snapshot, Process32First, Process32Next |
|
137 | # CreateToolhelp32Snapshot, Process32First, Process32Next | |
@@ -202,6 +203,12 b' except AttributeError:' | |||||
202 | _kernel32.SetConsoleCtrlHandler.argtypes = [_SIGNAL_HANDLER, _BOOL] |
|
203 | _kernel32.SetConsoleCtrlHandler.argtypes = [_SIGNAL_HANDLER, _BOOL] | |
203 | _kernel32.SetConsoleCtrlHandler.restype = _BOOL |
|
204 | _kernel32.SetConsoleCtrlHandler.restype = _BOOL | |
204 |
|
205 | |||
|
206 | _kernel32.SetConsoleMode.argtypes = [_HANDLE, _DWORD] | |||
|
207 | _kernel32.SetConsoleMode.restype = _BOOL | |||
|
208 | ||||
|
209 | _kernel32.GetConsoleMode.argtypes = [_HANDLE, ctypes.c_void_p] | |||
|
210 | _kernel32.GetConsoleMode.restype = _BOOL | |||
|
211 | ||||
205 | _kernel32.GetStdHandle.argtypes = [_DWORD] |
|
212 | _kernel32.GetStdHandle.argtypes = [_DWORD] | |
206 | _kernel32.GetStdHandle.restype = _HANDLE |
|
213 | _kernel32.GetStdHandle.restype = _HANDLE | |
207 |
|
214 | |||
@@ -372,6 +379,29 b' def termsize():' | |||||
372 | height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1 |
|
379 | height = csbi.srWindow.Bottom - csbi.srWindow.Top + 1 | |
373 | return width, height |
|
380 | return width, height | |
374 |
|
381 | |||
|
382 | def enablevtmode(): | |||
|
383 | '''Enable virtual terminal mode for the associated console. Return True if | |||
|
384 | enabled, else False.''' | |||
|
385 | ||||
|
386 | ENABLE_VIRTUAL_TERMINAL_PROCESSING = 0x4 | |||
|
387 | ||||
|
388 | handle = _kernel32.GetStdHandle(_STD_OUTPUT_HANDLE) # don't close the handle | |||
|
389 | if handle == _INVALID_HANDLE_VALUE: | |||
|
390 | return False | |||
|
391 | ||||
|
392 | mode = _DWORD(0) | |||
|
393 | ||||
|
394 | if not _kernel32.GetConsoleMode(handle, ctypes.byref(mode)): | |||
|
395 | return False | |||
|
396 | ||||
|
397 | if (mode.value & ENABLE_VIRTUAL_TERMINAL_PROCESSING) == 0: | |||
|
398 | mode.value |= ENABLE_VIRTUAL_TERMINAL_PROCESSING | |||
|
399 | ||||
|
400 | if not _kernel32.SetConsoleMode(handle, mode): | |||
|
401 | return False | |||
|
402 | ||||
|
403 | return True | |||
|
404 | ||||
375 | def _1stchild(pid): |
|
405 | def _1stchild(pid): | |
376 | '''return the 1st found child of the given pid |
|
406 | '''return the 1st found child of the given pid | |
377 |
|
407 |
General Comments 0
You need to be logged in to leave comments.
Login now