summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErik Rose <erik@mozilla.com>2011-11-14 15:40:59 -0800
committerErik Rose <erik@mozilla.com>2011-11-14 15:40:59 -0800
commit2b125bd4042bf9030f6c7dfaddef3f1e005fa7fd (patch)
treeff5fb18d9eb6b9927b2ee5b60209adbe9c9778e0
parent76c4894a263717845116464228b96eca48bb71e8 (diff)
downloadblessings-2b125bd4042bf9030f6c7dfaddef3f1e005fa7fd.tar.gz
Document is_a_tty attribute.
-rw-r--r--README.rst16
1 files changed, 13 insertions, 3 deletions
diff --git a/README.rst b/README.rst
index bffc330..6f6dd4e 100644
--- a/README.rst
+++ b/README.rst
@@ -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`_.