From 4c57a5cf4223b6c6085e3cfa60c8b1c908b98e48 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Fri, 23 Oct 2015 22:09:41 +0300 Subject: Fix flushing --- NEWS | 3 +++ ttystatus/messager.py | 4 ++-- ttystatus/status.py | 6 +++--- ttystatus/status_tests.py | 2 +- 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): -- cgit v1.2.1