summaryrefslogtreecommitdiff
path: root/tcvt.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2011-09-30 10:22:57 +0200
committerHelmut Grohne <helmut@subdivi.de>2011-09-30 10:22:57 +0200
commitd57a85ed8bbff98c6949f5b29ab3bd0d79dc555f (patch)
treef72446fd2420c045f8ec0f31530c3cbc063d1d44 /tcvt.py
parent14241474f697b3dcefcb81a5483658c05e4f59cf (diff)
downloadtcvt-d57a85ed8bbff98c6949f5b29ab3bd0d79dc555f.tar.gz
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.
Diffstat (limited to 'tcvt.py')
-rwxr-xr-xtcvt.py12
1 files changed, 11 insertions, 1 deletions
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()