diff options
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | ttystatus/status.py | 9 | ||||
-rw-r--r-- | ttystatus/status_tests.py | 8 |
3 files changed, 22 insertions, 0 deletions
@@ -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) |