#NEWLINE# def find_terminal_size( ) : #NEWLINE# #INDENT# "\n    Determine the number of lines and columns visible in the terminal.\n\n    :returns: A tuple of two integers with the line and column count.\n\n    The result of this function is based on the first of the following three\n    methods that works:\n\n    1. First :func:`find_terminal_size_using_ioctl()` is tried,\n    2. then :func:`find_terminal_size_using_stty()` is tried,\n    3. finally :data:`DEFAULT_LINES` and :data:`DEFAULT_COLUMNS` are returned.\n\n    .. note:: The :func:`find_terminal_size()` function performs the steps\n              above every time it is called, the result is not cached. This is\n              because the size of a virtual terminal can change at any time and\n              the result of :func:`find_terminal_size()` should be correct.\n\n              `Pre-emptive snarky comment`_: It's possible to cache the result\n              of this function and use :data:`signal.SIGWINCH` to refresh the\n              cached values!\n\n              Response: As a library I don't consider it the role of the\n              :py:mod:`humanfriendly.terminal` module to install a process wide\n              signal handler ...\n\n    .. _Pre-emptive snarky comment: http://blogs.msdn.com/b/oldnewthing/archive/2008/01/30/7315957.aspx\n    " #NEWLINE# for stream in ( sys . stdin , sys . stdout , sys . stderr ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# result = find_terminal_size_using_ioctl ( stream ) #NEWLINE# if ( min ( result ) >= 1 ) : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# try : #NEWLINE# #INDENT# result = find_terminal_size_using_stty ( ) #NEWLINE# if ( min ( result ) >= 1 ) : #NEWLINE# #INDENT# return result #NEWLINE# #UNINDENT# #UNINDENT# except Exception : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# return ( DEFAULT_LINES , DEFAULT_COLUMNS )