erikrose/blessings — pull request #41 by jquast (2013-09-24 05:25:09+00:00)
Title: Height width fallback

Most notably, is a new test-case using pty.fork(), that actually sets the virtual terminal's window size to a very small (3, 2) height and width, then asserts the return value of _height_and_width matches so.

This also includes a fall-through for test cases where the output stream is not a terminal, such as StringIO, and sys.stdout is also not a terminal, such as when the output is piped to tee(1). In such cases, the values found in the environment variables LINES, COLUMNS are used. Failing that, a default size of 80 x 24.

If a program using blessings were to mathematically use the terminal's height and width programatically, such as::

term.move_x(term.width / 2)

this would ensure an exception is not raised as previously would have been, in such rare cases, where width would be None. Because the output stream is very likely not a terminal, the move_x() sequence would become empty, anyway, but at least it would not throw an exception over it.