(fp)
| 295 | |
| 296 | |
| 297 | def _screen_shape_windows(fp): # pragma: no cover |
| 298 | try: |
| 299 | import struct |
| 300 | from ctypes import create_string_buffer, windll |
| 301 | from sys import stdin, stdout |
| 302 | |
| 303 | io_handle = -12 # assume stderr |
| 304 | if fp == stdin: |
| 305 | io_handle = -10 |
| 306 | elif fp == stdout: |
| 307 | io_handle = -11 |
| 308 | |
| 309 | h = windll.kernel32.GetStdHandle(io_handle) |
| 310 | csbi = create_string_buffer(22) |
| 311 | res = windll.kernel32.GetConsoleScreenBufferInfo(h, csbi) |
| 312 | if res: |
| 313 | (_bufx, _bufy, _curx, _cury, _wattr, left, top, right, bottom, |
| 314 | _maxx, _maxy) = struct.unpack("hhhhHhhhhhh", csbi.raw) |
| 315 | return right - left, bottom - top # +1 |
| 316 | except Exception: # nosec |
| 317 | pass |
| 318 | return None, None |
| 319 | |
| 320 | |
| 321 | def _screen_shape_tput(*_): # pragma: no cover |
nothing calls this directly
no outgoing calls
no test coverage detected