From 4e1cbc3ebeaa1bc12d8adb7a9dad284f9c8c4b9b Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Tue, 5 Aug 2025 02:43:22 +0200 Subject: [PATCH] Allow slash-free direct chatting in PRIVMSG windows. --- ircplom/client_tui.py | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/ircplom/client_tui.py b/ircplom/client_tui.py index c7e60c2..6245571 100644 --- a/ircplom/client_tui.py +++ b/ircplom/client_tui.py @@ -64,14 +64,33 @@ class _ClientWindow(Window, ClientQueueMixin): payload=IrcMessage(verb='PRIVMSG', params=(target, msg))) +class _PrivmsgPromptWidget(_ClientPromptWidget): + + def enter(self) -> str: + to_return = super().enter() + if (not to_return) or to_return[0:1] == '/': + return to_return + return f'/window.chat {to_return}' + + +class _PrivmsgWindow(_ClientWindow): + prompt: _PrivmsgPromptWidget + + def cmd__chat(self, msg: str) -> None: + 'PRIVMSG to .chat.' + self.cmd__privmsg(self.chat, msg) + + class ClientTui(BaseTui): 'TUI expanded towards Client features.' def _new_client_window(self, client_id: UUID, chat: str = '' ) -> _ClientWindow: new_idx = len(self.windows) - win = _ClientWindow(idx=new_idx, term=self.term, q_out=self.q_out, - client_id=client_id, chat=chat) + win_class = (_PrivmsgWindow if (chat and chat[0].isalpha()) + else _ClientWindow) + win = win_class(idx=new_idx, term=self.term, q_out=self.q_out, + client_id=client_id, chat=chat) self.windows += [win] self._switch_window(new_idx) return win -- 2.30.2