summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2012-05-21 10:59:31 +0300
committerLars Wirzenius <liw@liw.fi>2012-05-21 10:59:31 +0300
commit396be80da12390a5127939662c903350112df8ea (patch)
treed01312d9042fba16b0fb8bc7243922e28799f2e4
parent7666a2f35461769f462f7367cfa9053c91284a55 (diff)
downloadttystatus-396be80da12390a5127939662c903350112df8ea.tar.gz
Add TerminalStatus.flush method
-rw-r--r--NEWS5
-rw-r--r--ttystatus/status.py9
-rw-r--r--ttystatus/status_tests.py8
3 files changed, 22 insertions, 0 deletions
diff --git a/NEWS b/NEWS
index d9b8504..8d1d805 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,11 @@
NEWS file for ttystatus
=======================
+Version 0.19, released UNRELEASED
+---------------------------------
+
+* Added a `TerminalStatus.flush` method, to allow forcing an update.
+
Version 0.18, released 2012-05-08
---------------------------------
diff --git a/ttystatus/status.py b/ttystatus/status.py
index b98fecd..82457b2 100644
--- a/ttystatus/status.py
+++ b/ttystatus/status.py
@@ -73,6 +73,15 @@ class TerminalStatus(object):
w.update(self)
if self._m.time_to_write():
self._write()
+
+ def flush(self):
+ '''Force an update of current state to the screen.
+
+ This happens even if it is not yet time to output the screen.
+
+ '''
+
+ self._write()
def _render(self):
'''Render current state of all widgets.'''
diff --git a/ttystatus/status_tests.py b/ttystatus/status_tests.py
index ef8959a..daba040 100644
--- a/ttystatus/status_tests.py
+++ b/ttystatus/status_tests.py
@@ -113,6 +113,14 @@ class TerminalStatusTests(unittest.TestCase):
def test_has_finish_method(self):
self.assertEqual(self.ts.finish(), None)
+ def test_flushes(self):
+ self.ts._m.time_to_write = lambda: False
+ self.ts.format('%String(foo)')
+ self.ts['foo'] = 'foo'
+ self.assertEqual(self.ts._m.written.getvalue(), '')
+ self.ts.flush()
+ self.assertEqual(self.ts._m.written.getvalue(), 'foo')
+
def test_disable_calls_messager_disable(self):
self.ts.disable()
self.assertFalse(self.ts._m.enabled)