import curses
import itertools
+import os
import select
+import signal
import sys
import threading
else:
return None
- def add_selfpipe(self, url, handler):
+ def add_streaming_selfpipe(self, url, handler):
sp = util.SelfPipe()
gen = self.get_streaming_lines(url)
def threadfn():
th.start()
self.selfpipes.append((sp, handler, th))
+ def add_sigwinch_selfpipe(self):
+ sp = util.SelfPipe()
+ signal.signal(signal.SIGWINCH, lambda *args: sp.signal())
+ def handler():
+ size = os.get_terminal_size()
+ curses.resizeterm(size.lines, size.columns)
+ # This is the same way standard curses will do it, which
+ # is as good a way as any to signal to the main loop that
+ # we need to do something
+ curses.ungetch(curses.KEY_RESIZE)
+ self.selfpipes.append((sp, handler, None))
+
def run(self):
home_feed = self.home_timeline_feed()
- self.add_selfpipe("streaming/user", home_feed.extend_future)
+ self.add_streaming_selfpipe("streaming/user", home_feed.extend_future)
+ self.add_sigwinch_selfpipe()
self.home_timeline = StatusFile(
self, home_feed,
text.ColouredString("Home timeline <H>",