From: Simon Tatham Date: Wed, 6 Dec 2023 06:52:06 +0000 (+0000) Subject: Do SIGWINCH handling ourselves. X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=8df883c88bddcecdf990bfa4fa75628ec7738b27;p=mastodonochrome.git Do SIGWINCH handling ourselves. It broke as a side effect of going into nodelay mode, I think because our select loop didn't know to check curses's flag. --- diff --git a/cursesclient.py b/cursesclient.py index abf383b..564a7a0 100644 --- a/cursesclient.py +++ b/cursesclient.py @@ -1,6 +1,8 @@ import curses import itertools +import os import select +import signal import sys import threading @@ -112,7 +114,7 @@ class CursesUI(client.Client): 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(): @@ -124,9 +126,22 @@ class CursesUI(client.Client): 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 ",