From d57a85ed8bbff98c6949f5b29ab3bd0d79dc555f Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Fri, 30 Sep 2011 10:22:57 +0200 Subject: reduce screen.refresh() Previously it would refresh after at most 1024 bytes of output. With a slow terminal and much output this can be very annoying. So now we only refresh when there is no more output or a tenth of a second has passed since the last output. --- tcvt.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'tcvt.py') diff --git a/tcvt.py b/tcvt.py index 71f4567..a5c7462 100755 --- a/tcvt.py +++ b/tcvt.py @@ -38,6 +38,7 @@ import termios import struct import curses import errno +import time def init_color_pairs(): for bi, bc in enumerate((curses.COLOR_BLACK, curses.COLOR_RED, @@ -458,9 +459,11 @@ def main(): try: t.start() t.resizepty(masterfd) + refreshpending = None while True: try: - res, _, _ = select.select([0, masterfd], [], []) + res, _, _ = select.select([0, masterfd], [], [], + refreshpending and 0) except select.error, err: if err.args[0] == errno.EINTR: t.resized() @@ -490,7 +493,14 @@ def main(): break for char in data: t.feed(char) + if refreshpending is None: + refreshpending = time.time() + 0.1 + elif refreshpending is not None: t.screen.refresh() + refreshpending = None + if refreshpending is not None and refreshpending < time.time(): + t.screen.refresh() + refreshpending = None finally: t.stop() -- cgit v1.2.3