diff options
author | mathieui <mathieui@mathieui.net> | 2012-11-11 16:01:53 +0100 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2012-11-11 16:01:53 +0100 |
commit | 6781f67e80aa5ec86c84b49ef4526dcef9feceda (patch) | |
tree | 03b86fbcf9cc34fb8412558fec4e3c19c78a268d /src/text_buffer.py | |
parent | 844392a69aad39b37281f212b0a55c8a611575ac (diff) | |
download | poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.tar.gz poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.tar.bz2 poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.tar.xz poezio-6781f67e80aa5ec86c84b49ef4526dcef9feceda.zip |
Preload history into discussion windows (à la mcabber)
- New option load_log defaulting to 200 to indicate the number of lines
to be loaded
- It’s still very raw, and the format of the message does not match the
format of the normal room history, for example
- Works in the Private chat, MUC, and Conversation tabs
Thanks to labedz <github@labedz.org> for the original code
Diffstat (limited to 'src/text_buffer.py')
-rw-r--r-- | src/text_buffer.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/text_buffer.py b/src/text_buffer.py index 1dc042c6..f20c0cb9 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -35,7 +35,7 @@ class TextBuffer(object): def add_window(self, win): self.windows.append(win) - def make_message(self, txt, time, nickname, nick_color, history, user, identifier): + def make_message(self, txt, time, nickname, nick_color, history, user, identifier, str_time=None): time = time or datetime.now() if txt.startswith('/me '): if nick_color: @@ -47,15 +47,17 @@ class TextBuffer(object): # TODO: display the bg color too. txt = '\x19%(info_col)s}* \x19%(col)s}%(nick)s \x19%(info_col)s}%(msg)s' % {'info_col':get_theme().COLOR_ME_MESSAGE[0], 'col': color or 5, 'nick': nickname, 'msg': txt[4:]} nickname = None - msg = Message(txt='%s\x19o'%(txt.replace('\t', ' '),), nick_color=nick_color, - time=time, str_time=time.strftime("%Y-%m-%d %H:%M:%S")\ - if history else time.strftime("%H:%M:%S"),\ + msg = Message( + txt='%s\x19o'%(txt.replace('\t', ' '),), + nick_color=nick_color, + time=time, + str_time=(time.strftime("%Y-%m-%d %H:%M:%S") if history else time.strftime("%H:%M:%S")) if str_time is None else '', nickname=nickname, user=user, identifier=identifier) log.debug('Set message %s with %s.' % (identifier, msg)) return msg - def add_message(self, txt, time=None, nickname=None, nick_color=None, history=None, user=None, highlight=False, identifier=None): - msg = self.make_message(txt, time, nickname, nick_color, history, user, identifier) + def add_message(self, txt, time=None, nickname=None, nick_color=None, history=None, user=None, highlight=False, identifier=None, str_time=None): + msg = self.make_message(txt, time, nickname, nick_color, history, user, identifier, str_time) self.messages.append(msg) while len(self.messages) > self.messages_nb_limit: self.messages.pop(0) |