diff options
author | Erik Rose <erik@mozilla.com> | 2011-11-14 15:40:59 -0800 |
---|---|---|
committer | Erik Rose <erik@mozilla.com> | 2011-11-14 15:40:59 -0800 |
commit | 2b125bd4042bf9030f6c7dfaddef3f1e005fa7fd (patch) | |
tree | ff5fb18d9eb6b9927b2ee5b60209adbe9c9778e0 | |
parent | 76c4894a263717845116464228b96eca48bb71e8 (diff) | |
download | blessings-2b125bd4042bf9030f6c7dfaddef3f1e005fa7fd.tar.gz |
Document is_a_tty attribute.
-rw-r--r-- | README.rst | 16 |
1 files changed, 13 insertions, 3 deletions
@@ -194,14 +194,24 @@ If you want to override this--like if you anticipate your program being piped through ``less -r``, which handles terminal escapes just fine--pass ``force_styling=True`` to the ``Terminal`` constructor. +In any case, there is an ``is_a_tty`` attribute on ``Terminal`` that lets you +see whether the attached stream seems to be a terminal. If false, you might +refrain from drawing progress bars and other frippery, since you're apparently +headed into a pipe:: + + from blessings import Terminal + + term = Terminal() + if term.is_a_tty: + with term.location(0, term.height): + print 'Progress: [=======> ]' + print term.bold + 'Important stuff' + term.normal + Future Plans ============ * Comb through the terminfo man page for useful capabilities with confounding names, and add sugary attribute names for them. -* An ``is_terminal`` attr on ``Terminal`` that you can check before drawing - progress bars and other such things that are interesting only in a terminal - context * A relative-positioning version of ``location()`` Bugs or suggestions? Visit the `issue tracker`_. |