From 216aef7c9d7fac25d5def1df8b92cc7309809f84 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Thu, 5 Jun 2025 21:05:46 +0200 Subject: [PATCH] Add CONN_ALERT event type to alert specifically in connection window. --- ircplom.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ircplom.py b/ircplom.py index 54a8599..203c8b2 100755 --- a/ircplom.py +++ b/ircplom.py @@ -213,8 +213,8 @@ class IrcConnection: def _write_line(self, line: str) -> None: 'Send line-separator-delimited message over socket.' if not self._assumed_open: - self._q_to_main.eput('ALERT', - 'cannot send, assuming connection closed') + self._broadcast('CONN_ALERT', + 'cannot send, assuming connection closed') return self._socket.sendall(line.encode('utf-8') + IRCSPEC_LINE_SEPARATOR) @@ -622,6 +622,16 @@ class TuiLoop(Loop): elif event.type_ == 'ALERT': self.window.log.append(f'{event.type_} {event.payload}') self.window.log.draw() + elif event.type_ in {'RECV', 'SEND', 'CONN_ALERT'}: + conn_win = self._conn_windows[event.payload[0]] + if event.type_ == 'CONN_ALERT': + msg = f'ALERT {event.payload[1]}' + else: + msg = (('<-' if event.type_ == 'RECV' else '->') + + event.payload[1].raw) + conn_win.log.append(msg) + if conn_win == self.window: + self.window.log.draw() elif event.type_ in {'RECV', 'SEND'}: conn_win = self._conn_windows[event.payload[0]] prefix = '<-' if event.type_ == 'RECV' else '->' -- 2.30.2