summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
authorErik Rose <erik@mozilla.com>2011-12-12 21:04:46 -0800
committerErik Rose <erik@mozilla.com>2011-12-12 21:04:46 -0800
commit5d5748283e31a749a8d3d258fd750fed13948582 (patch)
tree44d4102cee91fbe481e8445b975fc7c9286b0015 /README.rst
parent14c34b9f7a0398fd33c7f1b8a0d13a8b47c8ebf0 (diff)
downloadblessings-5d5748283e31a749a8d3d258fd750fed13948582.tar.gz
Rejigger readme so code samples are at the top.1.3
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst50
1 files changed, 31 insertions, 19 deletions
diff --git a/README.rst b/README.rst
index 4104866..59983de 100644
--- a/README.rst
+++ b/README.rst
@@ -1,26 +1,41 @@
-==========
+=========
Blessings
-==========
+=========
-by Erik Rose
+Coding with Blessings looks like this... ::
-The Pitch
-=========
+ from blessings import Terminal
+
+ t = Terminal()
-curses is a fine library, but there are a couple situations where it doesn't
-fit:
+ print t.bold('Hi there!')
+ print t.bold_red_on_bright_green('It hurts my eyes!')
-* You want to use bold, color, and maybe a little positioning without clearing
- the whole screen first.
-* You want to leave more than one screenful of scrollback in the buffer after
- your program exits.
+ with t.location(0, t.height - 1):
+ print 'This is at the bottom.'
+
+Or, for byte-level control, you can drop down and play with raw terminal
+capabilities::
+
+ print '{t.bold}All your {t.red}bold and red base{t.normal}'.format(t=t)
+ print t.wingo(2)
+
+The Pitch
+=========
-In essence, you want to act like a well-behaved command-line app, not a
-full-screen pseudo-GUI one. Or...
+Blessings lifts several of curses_' limiting assumptions, and it makes your
+code pretty, too:
-* You just want to get the noise out of your code.
+* Use styles, color, and maybe a little positioning without clearing the whole
+ screen first.
+* Leave more than one screenful of scrollback in the buffer after your program
+ exits, like a well-behaved command-line app should.
+* Get rid of all those noisy, C-like calls to ``tigetstr`` and ``tparm``, so
+ your code doesn't get crowded out by terminal bookkeeping.
+* Act intelligently when somebody redirects your output to a file, omitting the
+ terminal control codes the user doesn't want to see (optional).
-If these sound good, Blessings is for you.
+.. _curses: http://docs.python.org/library/curses.html
Before And After
----------------
@@ -64,10 +79,7 @@ this time with Blessings::
with term.location(0, term.height - 1):
print 'This is', term.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
-redirects your output to a file, omitting the terminal control codes you don't
-want to see.
+Much better.
What It Provides
================