MCPcopy Index your code
hub / github.com/RustPython/RustPython / getheightwidth

Method getheightwidth

Lib/_pyrepl/unix_console.py:443–460  ·  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

441 if TIOCGWINSZ:
442
443 def getheightwidth(self):
444 """
445 Get the height and width of the console.
446
447 Returns:
448 - tuple: Height and width of the console.
449 """
450 try:
451 return int(os.environ["LINES"]), int(os.environ["COLUMNS"])
452 except (KeyError, TypeError, ValueError):
453 try:
454 size = ioctl(self.input_fd, TIOCGWINSZ, b"\000" * 8)
455 except OSError:
456 return 25, 80
457 height, width = struct.unpack("hhhh", size)[0:2]
458 if not height:
459 return 25, 80
460 return height, width
461
462 else:
463

Callers 2

prepareMethod · 0.95
__sigwinchMethod · 0.95

Calls 2

ioctlFunction · 0.90
unpackMethod · 0.45

Tested by

no test coverage detected