diff options
author | Erik Rose <erik@mozilla.com> | 2012-02-01 14:03:20 -0800 |
---|---|---|
committer | Erik Rose <erik@mozilla.com> | 2012-02-01 14:03:20 -0800 |
commit | 103f089a2081a83a1d0fc471c2aa484ce30da407 (patch) | |
tree | b5f1d8443cf8fec85095acf4d65c75bec2838953 /blessings | |
parent | 4ab628f086ad697243159d4700a5e661297d748d (diff) | |
download | blessings-103f089a2081a83a1d0fc471c2aa484ce30da407.tar.gz |
Document an idiom for restoring the cursor location after a series of manual moves. Closes #17.
Diffstat (limited to 'blessings')
-rw-r--r-- | blessings/__init__.py | 5 | ||||
-rw-r--r-- | blessings/tests.py | 9 |
2 files changed, 13 insertions, 1 deletions
diff --git a/blessings/__init__.py b/blessings/__init__.py index 080fe26..dbd4b69 100644 --- a/blessings/__init__.py +++ b/blessings/__init__.py @@ -213,7 +213,10 @@ class Terminal(object): print 'I can do it %i times!' % x Specify ``x`` to move to a certain column, ``y`` to move to a certain - row, or both. + row, both, or neither. If you specify neither, only the saving and + restoration of cursor position will happen. This can be useful if you + simply want to restore your place after doing some manual cursor + movement. """ return Location(self, x, y) diff --git a/blessings/tests.py b/blessings/tests.py index a02a392..72236ae 100644 --- a/blessings/tests.py +++ b/blessings/tests.py @@ -102,6 +102,15 @@ def test_horizontal_location(): unicode_cap('rc')) +def test_null_location(): + """Make sure ``location()`` with no args just does position restoration.""" + t = TestTerminal(stream=StringIO(), force_styling=True) + with t.location(): + pass + eq_(t.stream.getvalue(), unicode_cap('sc') + + unicode_cap('rc')) + + def test_null_fileno(): """Make sure ``Terminal`` works when ``fileno`` is ``None``. |