summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2015-10-23 22:09:41 +0300
committerLars Wirzenius <liw@liw.fi>2015-10-23 22:09:41 +0300
commit4c57a5cf4223b6c6085e3cfa60c8b1c908b98e48 (patch)
tree1fdaba56117f49ab86ee38b9ed94eebd8d3836a2
parent4d3769889e4c23bf240154c78c41dee9042b4fe5 (diff)
downloadttystatus-4c57a5cf4223b6c6085e3cfa60c8b1c908b98e48.tar.gz
Fix flushing
-rw-r--r--NEWS3
-rw-r--r--ttystatus/messager.py4
-rw-r--r--ttystatus/status.py6
-rw-r--r--ttystatus/status_tests.py2
4 files changed, 9 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 3a1a4ea..6b7d18a 100644
--- a/NEWS
+++ b/NEWS
@@ -8,6 +8,9 @@ Version 0.31, released UNRELEASED
itself by the `TerminalStatus.notify` method not removing an
existing status message before writing out the notification.
+* Fix bug in `TerminalStatus.flush` that meant it did not, in fact,
+ flush the output.
+
Version 0.30, released 2015-10-17
---------------------------------
diff --git a/ttystatus/messager.py b/ttystatus/messager.py
index 15f75fb..91206bb 100644
--- a/ttystatus/messager.py
+++ b/ttystatus/messager.py
@@ -76,14 +76,14 @@ class Messager(object):
def get_max_line_length(self):
return self._area.get_max_line_length()
- def write(self, message):
+ def write(self, message, force=False):
'''Write message to terminal.
Message may be multiple lines.
'''
- if self.enabled and self.time_to_write():
+ if self.enabled and (force or self.time_to_write()):
self.clear()
num_lines = len(message.split('\n'))
self._area.make_space(num_lines)
diff --git a/ttystatus/status.py b/ttystatus/status.py
index 1760f8a..debd576 100644
--- a/ttystatus/status.py
+++ b/ttystatus/status.py
@@ -122,7 +122,7 @@ class TerminalStatus(object):
'''
- self._write()
+ self._write(force=True)
def _render(self):
'''Render current state of all widgets.'''
@@ -154,9 +154,9 @@ class TerminalStatus(object):
c if ord(c) >= ASCII_SPACE else ''
for c in line.expandtabs())
- def _write(self):
+ def _write(self, force=False):
'''Render and output current state of all widgets.'''
- self._m.write(self._render())
+ self._m.write(self._render(), force=force)
def increase(self, key, delta):
'''Increase value for a key by a given amount.'''
diff --git a/ttystatus/status_tests.py b/ttystatus/status_tests.py
index ecf91f9..92425ac 100644
--- a/ttystatus/status_tests.py
+++ b/ttystatus/status_tests.py
@@ -36,7 +36,7 @@ class DummyMessager(object):
def time_to_write(self):
return True
- def write(self, string):
+ def write(self, string, force=False):
self.written.write(string)
def notify(self, string, f, force=False):