diff options
author | mathieui <mathieui@mathieui.net> | 2019-09-29 18:12:48 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2020-05-09 19:46:17 +0200 |
commit | a5e92800477f6195a6b2e8c6e64a56859117d5b8 (patch) | |
tree | f53550024091a12deeee88c0d9897d0aeba9f4bf /poezio/ui/types.py | |
parent | fefbb0b08887b761ad7a1cf95cf6b9f5f30013a6 (diff) | |
download | poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.tar.gz poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.tar.bz2 poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.tar.xz poezio-a5e92800477f6195a6b2e8c6e64a56859117d5b8.zip |
Pass a message to add_message instead of messed up kwargs everywhere
Changes LOTS of things
Diffstat (limited to 'poezio/ui/types.py')
-rw-r--r-- | poezio/ui/types.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/poezio/ui/types.py b/poezio/ui/types.py index 6c744ac3..9ecdc185 100644 --- a/poezio/ui/types.py +++ b/poezio/ui/types.py @@ -27,6 +27,12 @@ class BaseMessage: return SHORT_FORMAT_LENGTH + 1 +class InfoMessage(BaseMessage): + def __init__(self, txt: str, identifier: str = '', time: Optional[datetime] = None): + txt = ('\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT)) + txt + super().__init__(txt=txt, identifier=identifier, time=time) + + class XMLLog(BaseMessage): """XML Log message""" __slots__ = ('txt', 'time', 'identifier', 'incoming') @@ -59,6 +65,25 @@ class XMLLog(BaseMessage): return offset +class StatusMessage(BaseMessage): + __slots__ = ('txt', 'time', 'identifier', 'format_string', 'format_args') + + def __init__(self, format_string: str, format_args: dict): + BaseMessage.__init__( + self, + txt='', + ) + self.format_string = format_string + self.format_args = format_args + self.rebuild() + + def rebuild(self): + real_args = {} + for key, func in self.format_args.items(): + real_args[key] = func() + self.txt = self.format_string.format(**real_args) + + class Message(BaseMessage): __slots__ = ('txt', 'nick_color', 'time', 'nickname', 'user', 'history', 'identifier', 'top', 'highlight', 'me', 'old_message', 'revisions', |