home · contact · privacy
Simplify ClientWindow.title/.chatname usage.
authorChristian Heller <c.heller@plomlompom.de>
Sun, 5 Oct 2025 05:43:17 +0000 (07:43 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Sun, 5 Oct 2025 05:43:17 +0000 (07:43 +0200)
src/ircplom/client_tui.py
src/tests/test.test

index 08fbbfd39ca76e69aeb28147d16f0c3cd0e2caf9..00ec46fb378005ac54d5300574f4c546354c8358 100644 (file)
@@ -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())
index f15fc0a3895609d9118d370d41bf7da70cac172e..4bff1a7e47ecafbb90d9540533742dfb312d0880 100644 (file)
 > /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