home · contact · privacy
Refactor event loop, always pass to TUI.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 13:12:53 +0000 (15:12 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 30 May 2025 13:12:53 +0000 (15:12 +0200)
ircplom.py

index ef58fe6e2cc64b5df50e100782ceac62df879612..b090868b3c5889a3e5c221faad1c5b010dc2fd1f 100755 (executable)
@@ -376,6 +376,8 @@ class TuiLoop(Loop):
         #         f'DEBUG {line}' for line
         #         in '\n'.join(format_exception(event.payload)).split('\n')]
         #     self._draw_log()
+        else:
+            return True
         self._term.flush()
         return True
 
@@ -438,24 +440,16 @@ def run() -> None:
             q_to_main.put(Event('SEND', IrcMessage('NICK', [NICKNAME])))
             while True:
                 event = q_to_main.get()
+                term.tui.put(event)
                 if event.type_ == 'QUIT':
                     break
-                if event.type_ == 'INPUT_PROMPT':
-                    term.tui.put(event)
-                elif event.type_ == 'SEND':
-                    term.tui.put(event)
+                if event.type_ == 'EXCEPTION':
+                    raise event.payload
+                if event.type_ == 'SEND':
                     event.payload.send(conn)
                 elif event.type_ == 'PING':
                     q_to_main.put(
                         Event('SEND', IrcMessage('PONG', [event.payload])))
-                elif event.type_ == 'RECV':
-                    term.tui.put(event)
-                elif event.type_ == 'EXCEPTION':
-                    raise event.payload
-                elif event.type_ == 'ALERT':
-                    term.tui.put(event)
-                # elif event.type_ == 'DEBUG':
-                #     term.tui.put(event)
 
 
 if __name__ == '__main__':