From 4ab628f086ad697243159d4700a5e661297d748d Mon Sep 17 00:00:00 2001 From: Erik Rose Date: Mon, 19 Dec 2011 15:33:20 -0800 Subject: Sugar cursor-visibility and single-space-movement capabilities. Closes #15. --- README.rst | 4 ++-- blessings/__init__.py | 15 +++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.rst b/README.rst index 692fff5..07dd4f6 100644 --- a/README.rst +++ b/README.rst @@ -100,8 +100,8 @@ available as attributes on a ``Terminal``. For example:: term = Terminal() print 'I am ' + term.bold + 'bold' + term.normal + '!' -You can also use them as wrappers so you don't have to say ``normal`` -afterward:: +Though they are strings at heart, you can also use them as callable wrappers so +you don't have to say ``normal`` afterward:: print 'I am', term.bold('bold') + '!' diff --git a/blessings/__init__.py b/blessings/__init__.py index 081288b..080fe26 100644 --- a/blessings/__init__.py +++ b/blessings/__init__.py @@ -7,7 +7,6 @@ try: except ImportError: class IOUnsupportedOperation(Exception): """A dummy exception to take the place of Python 3's ``io.UnsupportedOperation`` in Python 2""" - pass import os from os import isatty, environ from platform import python_version_tuple @@ -16,15 +15,15 @@ import sys from termios import TIOCGWINSZ +__all__ = ['Terminal'] + + if ('3', '0', '0') <= python_version_tuple() < ('3', '2', '2+'): # Good till 3.2.10 # Python 3.x < 3.2.3 has a bug in which tparm() erroneously takes a string. raise ImportError('Blessings needs Python 3.2.3 or greater for Python 3 ' 'support due to http://bugs.python.org/issue10570.') -__all__ = ['Terminal'] - - class Terminal(object): """An abstraction around terminal capabilities @@ -111,10 +110,18 @@ class Terminal(object): clear_eol='el', clear_bol='el1', clear_eos='ed', + # 'clear' clears the whole screen. position='cup', # deprecated move='cup', move_x='hpa', move_y='vpa', + move_left='cub1', + move_right='cuf1', + move_up='cuu1', + move_down='cud1', + + hide_cursor='civis', + normal_cursor='cnorm', reset_colors='op', # oc doesn't work on my OS X terminal. -- cgit v1.2.1