summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
authorErik Rose <erik@mozilla.com>2011-11-20 21:13:19 -0800
committerErik Rose <erik@mozilla.com>2011-11-20 21:13:19 -0800
commitd03d43c4c9722b91056283fba44a4945efc41943 (patch)
tree463cc51286cecb0d67d84fac8fc3cde8fc057af3 /README.rst
parent5963fd875707193349af6b77ec9dff280b46811f (diff)
downloadblessings-d03d43c4c9722b91056283fba44a4945efc41943.tar.gz
Polish readme a bit.
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst27
1 files changed, 20 insertions, 7 deletions
diff --git a/README.rst b/README.rst
index 496ef79..c5aabd7 100644
--- a/README.rst
+++ b/README.rst
@@ -16,11 +16,17 @@ fit:
your program exits.
In essence, you want to act like a well-behaved command-line app, not a
-full-screen pseudo-GUI one. Or maybe you just want to get the noise out of your
-code.
+full-screen pseudo-GUI one. Or...
-If either of these sounds good, Blessings is for you. Without it, this is how
-you'd print some underlined text at the bottom of the screen::
+* You just want to get the noise out of your code.
+
+If these sound good, Blessings is for you.
+
+Before And After
+----------------
+
+Without Blessings, this is how you'd print some underlined text at the bottom
+of the screen::
from curses import tigetstr, setupterm, tparm
from fcntl import ioctl
@@ -56,7 +62,7 @@ this time with Blessings::
term = Terminal()
with term.location(0, term.height):
- print 'This is {t.underline}underlined{t.no_underline}!'.format(t=term)
+ print 'This is', t.underline('pretty!')
It's short, it's obvious, and it keeps all those nasty ``tigetstr()`` and
``tparm()`` calls out of your code. It also acts intelligently when somebody
@@ -75,17 +81,24 @@ Simple Formatting
-----------------
Lots of handy formatting codes ("capabilities" in low-level parlance) are
-available as attributes on ``Terminal`` instances. For example::
+available as attributes on a ``Terminal``. For example::
from blessings import Terminal
term = Terminal()
print 'I am ' + term.bold + 'bold' + term.normal + '!'
-Or you can use them as wrappers so you don't have to say ``normal`` afterward::
+You can also use them as wrappers so you don't have to say ``normal``
+afterward::
print 'I am', term.bold('bold') + '!'
+Or, if you want fine-grained control while maintaining some semblance of
+brevity, you can combine it with Python's string formatting, which makes
+attributes easy to access::
+
+ print 'All your {t.red}base {t.underline}are belong to us{t.normal}'.format(t=term)
+
Simple capabilities of interest include...
* ``bold``