MCPcopy Index your code
hub / github.com/python/cpython / getheightwidth

Method getheightwidth

Lib/_pyrepl/unix_console.py:463–480  ·  view source on GitHub ↗

Get the height and width of the console. Returns: - tuple: Height and width of the console.

(self)

Source from the content-addressed store, hash-verified

461 if TIOCGWINSZ:
462
463 def getheightwidth(self):
464 """
465 Get the height and width of the console.
466
467 Returns:
468 - tuple: Height and width of the console.
469 """
470 try:
471 return int(os.environ["LINES"]), int(os.environ["COLUMNS"])
472 except (KeyError, TypeError, ValueError):
473 try:
474 size = ioctl(self.input_fd, TIOCGWINSZ, b"\000" * 8)
475 except OSError:
476 return 25, 80
477 height, width = struct.unpack("hhhh", size)[0:2]
478 if not height:
479 return 25, 80
480 return height, width
481
482 else:
483

Callers 3

prepareMethod · 0.95
__sigwinchMethod · 0.95

Calls 2

ioctlFunction · 0.85
unpackMethod · 0.80