diff options
author | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-08 22:28:36 (GMT) |
---|---|---|
committer | Antoine Pitrou <solipsis@pitrou.net> | 2012-02-08 22:28:36 (GMT) |
commit | bcf2b59fb5f18c09a26da3e9b60a37367f2a28ba (patch) | |
tree | 47232d9eb97758190b44700163d2706665224d7c /Doc/library/os.rst | |
parent | 4195b5caea0fe1446160e78d69420732ead7e78b (diff) | |
download | cpython-bcf2b59fb5f18c09a26da3e9b60a37367f2a28ba.zip cpython-bcf2b59fb5f18c09a26da3e9b60a37367f2a28ba.tar.gz cpython-bcf2b59fb5f18c09a26da3e9b60a37367f2a28ba.tar.bz2 |
Issue #13609: Add two functions to query the terminal size:
os.get_terminal_size (low level) and shutil.get_terminal_size (high level).
Patch by Zbigniew Jędrzejewski-Szmek.
Diffstat (limited to 'Doc/library/os.rst')
-rw-r--r-- | Doc/library/os.rst | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/Doc/library/os.rst b/Doc/library/os.rst index 06f1452..c3dfb3d 100644 --- a/Doc/library/os.rst +++ b/Doc/library/os.rst @@ -1411,6 +1411,43 @@ or `the MSDN <http://msdn.microsoft.com/en-us/library/z0kc8e3z.aspx>`_ on Window .. versionadded:: 3.3 +.. _terminal-size: + +Querying the size of a terminal +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. versionadded:: 3.3 + +.. function:: get_terminal_size(fd=STDOUT_FILENO) + + Return the size of the terminal window as ``(columns, lines)``, + tuple of type :class:`terminal_size`. + + The optional argument ``fd`` (default ``STDOUT_FILENO``, or standard + output) specifies which file descriptor should be queried. + + If the file descriptor is not connected to a terminal, an :exc:`OSError` + is thrown. + + :func:`shutil.get_terminal_size` is the high-level function which + should normally be used, ``os.get_terminal_size`` is the low-level + implementation. + + Availability: Unix, Windows. + +.. class:: terminal_size(tuple) + + A tuple of ``(columns, lines)`` for holding terminal window size. + + .. attribute:: columns + + Width of the terminal window in characters. + + .. attribute:: lines + + Height of the terminal window in characters. + + .. _os-file-dir: Files and Directories |