Skip to content
Myr

Use shutil.get_terminal_size if available

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Paul Moore · committed by Paul Moore · parent 8ca33a9 · Browse files · 1 file+7 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+7 added−0 removed

  • other:+7 added−0 removed

1 file+7 added−0 removed

modified:click.py+7 added
19 unmodified lines
20import getpass21import optparse22import textwrap23import struct24import shutil25from itertools import chain26from functools import update_wrapper2728
43 unmodified lines
72def get_terminal_size():73 """Returns the current size of the terminal as tuple in the form74 ``(width, height)`` in columns and rows.75 """76 # If shutil has get_terminal_size() (Python 3.3 and later) use that77 shutil_get_terminal_size = getattr(shutil, 'get_terminal_size', None)78 if shutil_get_terminal_size:79 sz = shutil_get_terminal_size()80 return sz.columns, sz.lines8182 def ioctl_gwinsz(fd):83 try:84 import fcntl85 import termios
1552 unmodified lines