MCPcopy Create free account
hub / github.com/PierreGode/Ragnar / _screen_shape_windows

Function _screen_shape_windows

pager_lib/tqdm/utils.py:297–318  ·  view source on GitHub ↗
(fp)

Source from the content-addressed store, hash-verified

295
296
297def _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
321def _screen_shape_tput(*_): # pragma: no cover

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected