CHAT = auto()
USER = auto()
USER_NO_CHANNELS = auto()
+ SERVER = auto()
class _ClientWindow(Window, ClientQueueMixin):
_title_separator = ':'
_logpath_prefix = '!'
+ _title: str
def __init__(self, path_logs: Optional[Path], **kwargs) -> None:
self._path_logs = path_logs
super().__init__(**kwargs)
- self._title = 'DEBUG'
@property
def title(self) -> str:
self._send_msg(verb, tuple(params))
+class _DebugWindow(_ClientWindow):
+ prompt: PromptWidget
+ _title = 'debug'
+
+
+class _ServerWindow(_ClientWindow):
+ prompt: PromptWidget
+ _title = 'server'
+
+
class _ChatPrompt(PromptWidget):
_nickname: str = ''
_title_separator = '/'
_logpath_prefix = ''
- def __init__(self, chatname: str, get_nick_data: Callable, **kwargs
+ def __init__(self, title: str, get_nick_data: Callable, **kwargs
) -> None:
+ self._title = title
self._get_nick_data = get_nick_data
- self.chatname = chatname
super().__init__(**kwargs)
- self._title = chatname
+ self.chatname = self._title
self.set_prompt_prefix()
def set_prompt_prefix(self) -> None:
update.results += [(_LogScope.ALL, [':DISCONNECTED'])]
elif update.key == 'message' and update.value:
assert isinstance(update.value, ChatMessage)
+ is_server_msg = not (update.value.sender or update.value.target)
toks = [':*** '] if update.value.is_notice else []
toks += [':[']
toks += [f':{update.value.sender}' if update.value.sender
- else 'NICK:me']
+ else (':server' if is_server_msg else 'NICK:me')]
toks += [f':] {update.value.content}']
- update.results += [(_LogScope.CHAT, toks)]
+ update.results += [
+ (_LogScope.SERVER if is_server_msg else _LogScope.CHAT, toks)]
class _ClientWindowsManager:
self.db = _TuiClientDb()
self.windows: list[_ClientWindow] = []
- def _new_win(self, scope: _LogScope, chatname: str = '') -> _ClientWindow:
+ def _new_win(self, scope: _LogScope, title: str = '') -> _ClientWindow:
if scope == _LogScope.CHAT:
win = self._tui_new_window(
- chatname=chatname, path_logs=self._path_logs,
- win_cls=(_ChannelWindow if self.db.is_chan_name(chatname)
+ title=title, path_logs=self._path_logs,
+ win_cls=(_ChannelWindow if self.db.is_chan_name(title)
else _QueryWindow),
get_nick_data=lambda: (self.db.users['me'].nick
if 'me' in self.db.users.keys()
else '?'))
else:
- win = self._tui_new_window(win_cls=_ClientWindow,
- path_logs=self._path_logs)
+ win = self._tui_new_window(path_logs=self._path_logs, win_cls=(
+ _ServerWindow if scope == _LogScope.SERVER else _DebugWindow))
self.windows += [win]
return win
if scope == _LogScope.ALL:
ret = [w for w in self.windows
if w not in self.windows_for(_LogScope.DEBUG)]
+ elif scope == _LogScope.SERVER:
+ ret = [w for w in self.windows if isinstance(w, _ServerWindow)]
elif scope == _LogScope.DEBUG:
- ret = [w for w in self.windows if not isinstance(w, _ChatWindow)]
+ ret = [w for w in self.windows if isinstance(w, _DebugWindow)]
elif scope == _LogScope.CHAT:
ret = [w for w in self.windows
if isinstance(w, _ChatWindow) and w.chatname == id_]
elif scope == _LogScope.USER_NO_CHANNELS:
ret = [w for w in self.windows_for(_LogScope.USER, id_)
if isinstance(w, _QueryWindow)]
- if (not ret) and scope in {_LogScope.CHAT, _LogScope.DEBUG}:
+ if (not ret) and scope in {_LogScope.CHAT,
+ _LogScope.SERVER, _LogScope.DEBUG}:
ret += [self._new_win(scope, id_)]
ret.sort(key=lambda w: w.idx)
return ret
target = ''
if update.full_path == ('message',):
target = update.value.target or update.value.sender
- out = not bool(update.value.sender)
+ out = not bool(update.value.sender
+ or scope == _LogScope.SERVER)
elif scope in {_LogScope.CHAT, _LogScope.USER,
_LogScope.USER_NO_CHANNELS}:
target = update.full_path[1]
# expect some NOTICE and PING to process/reply during initiation
:0:1 ..< :*.?.net NOTICE * :*** Looking up your ident...
-2 ..< *** [ server] *** Looking up your ident...
+2 ..< *** [server] *** Looking up your ident...
:0:1 ..< :*.?.net NOTICE * :*** Looking up your hostname...
-2 ..< *** [ server] *** Looking up your hostname...
+2 ..< *** [server] *** Looking up your hostname...
:0:1 ..< :*.?.net NOTICE * :*** Found your hostname (foo.bar.baz)
-2 ..< *** [ server] *** Found your hostname (foo.bar.baz)
+2 ..< *** [server] *** Found your hostname (foo.bar.baz)
:0:1 ..< PING :?
1 ..> PONG :?
> /list
0 ..# windows available via /window:
0 ..# 0) :start
-0 ..# 1) foo.bar.baz:DEBUG
-0 ..# 2) foo.bar.baz/ server
+0 ..# 1) foo.bar.baz:debug
+0 ..# 2) foo.bar.baz:server
0 ..# 3) foo.bar.baz/SaslServ
| conn5
> /window 1
1 ..> QUIT :ircplom says bye
:0:1 ..< :foo1!~foobarbaz@baz.bar.foo QUIT :Client Quit
1 ..$ users:me:exit_msg set to: [QClient Quit]
-2,3,6,7 ..$ foo1!~foobarbaz@baz.bar.foo quits: Client Quit
+3,6,7 ..$ foo1!~foobarbaz@baz.bar.foo quits: Client Quit
1 ..$ channels:#testtest:exits:me set to: [QClient Quit]
1 ..$ channels:#testtest:user_ids set to:
5 ..$ foo1!~foobarbaz@baz.bar.foo quits: Client Quit