Use os.get_terminal_size()

tput is part of ncurses, which may not be installed.

It still falls back to tput for older Python versions (this was
introduced in 3.3) or for platforms which may not support it.

Fixes #418
This commit is contained in:
Martin Tournoij
2020-12-06 14:31:33 +08:00
committed by Marcin Kulik
parent d6557c76ef
commit 80c9d3dbdc

View File

@@ -33,7 +33,9 @@ def read_blocking(fd, timeout):
def get_size():
# TODO maybe use os.get_terminal_size ?
try:
return os.get_terminal_size()
except:
return (
int(subprocess.check_output(['tput', 'cols'])),
int(subprocess.check_output(['tput', 'lines']))