From: Christian Heller Date: Sun, 5 Oct 2025 05:43:17 +0000 (+0200) Subject: Simplify ClientWindow.title/.chatname usage. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/add_free?a=commitdiff_plain;h=48a776c625280ba3de5497eb897a6d5ee98dc4d3;p=ircplom Simplify ClientWindow.title/.chatname usage. --- diff --git a/src/ircplom/client_tui.py b/src/ircplom/client_tui.py index 08fbbfd..00ec46f 100644 --- a/src/ircplom/client_tui.py +++ b/src/ircplom/client_tui.py @@ -43,15 +43,17 @@ class _LogScope(Enum): class _ClientWindow(Window, ClientQueueMixin): + _title_separator = ':' + _logpath_prefix = '!' def __init__(self, path_logs: Optional[Path], **kwargs) -> None: self._path_logs = path_logs super().__init__(**kwargs) - self._title = ':DEBUG' + self._title = 'DEBUG' @property def title(self) -> str: - return f'{self.client_id} {self._title}' + return f'{self.client_id}{self._title_separator}{self._title}' def log(self, msg: str) -> None: super().log(msg) @@ -69,7 +71,8 @@ class _ClientWindow(Window, ClientQueueMixin): ret += '_' return ret client_path = _PATH_LOGS.joinpath(escaped(self.client_id)) - chat_path = client_path.joinpath(escaped(self._title)) + chat_path = client_path.joinpath(self._logpath_prefix + + escaped(self._title)) if not chat_path.exists(): chat_path.mkdir(parents=True) with chat_path.joinpath(f'{self._last_today}.txt' @@ -131,19 +134,17 @@ class _ChatPrompt(PromptWidget): class _ChatWindow(_ClientWindow): prompt: _ChatPrompt + _title_separator = '/' + _logpath_prefix = '' def __init__(self, chatname: str, get_nick_data: Callable, **kwargs ) -> None: self._get_nick_data = get_nick_data + self.chatname = chatname super().__init__(**kwargs) self._title = chatname self.set_prompt_prefix() - @property - def chatname(self) -> str: - 'Name of channel or user with whom we chat.' - return self._title - def set_prompt_prefix(self) -> None: 'Look up relevant DB data to update prompt prefix.' self.prompt.set_prefix_data(self._get_nick_data()) diff --git a/src/tests/test.test b/src/tests/test.test index f15fc0a..4bff1a7 100644 --- a/src/tests/test.test +++ b/src/tests/test.test @@ -131,9 +131,9 @@ > /list 0 ..# windows available via /window: 0 ..# 0) :start -0 ..# 1) foo.bar.baz :DEBUG -0 ..# 2) foo.bar.baz server -0 ..# 3) foo.bar.baz SaslServ +0 ..# 1) foo.bar.baz:DEBUG +0 ..# 2) foo.bar.baz/ server +0 ..# 3) foo.bar.baz/SaslServ | conn5 > /window 1 > /help