From: Christian Heller Date: Thu, 5 Jun 2025 19:05:46 +0000 (+0200) Subject: Add CONN_ALERT event type to alert specifically in connection window. X-Git-Url: https://plomlompom.com/repos/%22https:/validator.w3.org/tasks?a=commitdiff_plain;h=216aef7c9d7fac25d5def1df8b92cc7309809f84;p=ircplom Add CONN_ALERT event type to alert specifically in connection window. --- 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 '->'