diff options
author | mathieui <mathieui@mathieui.net> | 2014-04-07 01:25:30 +0200 |
---|---|---|
committer | mathieui <mathieui@mathieui.net> | 2014-04-07 01:25:30 +0200 |
commit | 1ce485c6faa15f624dcc79b3260bf3a9899b5cee (patch) | |
tree | 2e2da40dab7babf528853b3d0fd92ef4485abb8c /src | |
parent | 53040305ce97bd532bd27cf0c2f626136f34a572 (diff) | |
download | poezio-1ce485c6faa15f624dcc79b3260bf3a9899b5cee.tar.gz poezio-1ce485c6faa15f624dcc79b3260bf3a9899b5cee.tar.bz2 poezio-1ce485c6faa15f624dcc79b3260bf3a9899b5cee.tar.xz poezio-1ce485c6faa15f624dcc79b3260bf3a9899b5cee.zip |
Fix #2354 (logs are badly colored with xhtml history)
- now it should work properly
- add a COLOR_LOG_MSG theming option, used both for local and remote
history
Diffstat (limited to 'src')
-rw-r--r-- | src/logger.py | 2 | ||||
-rw-r--r-- | src/tabs/muctab.py | 4 | ||||
-rw-r--r-- | src/text_buffer.py | 4 | ||||
-rw-r--r-- | src/theming.py | 1 | ||||
-rw-r--r-- | src/windows.py | 12 |
5 files changed, 18 insertions, 5 deletions
diff --git a/src/logger.py b/src/logger.py index e758bdc0..7ed0692f 100644 --- a/src/logger.py +++ b/src/logger.py @@ -151,7 +151,7 @@ class Logger(object): lines = m[pos-1:].decode(errors='replace').splitlines() messages = [] - color = '\x19%s}' % dump_tuple(get_theme().COLOR_INFORMATION_TEXT) + color = '\x19%s}' % dump_tuple(get_theme().COLOR_LOG_MSG) # now convert that data into actual Message objects idx = 0 diff --git a/src/tabs/muctab.py b/src/tabs/muctab.py index bb094bbf..8953d075 100644 --- a/src/tabs/muctab.py +++ b/src/tabs/muctab.py @@ -1202,7 +1202,9 @@ class MucTab(ChatTab): if self.state != 'highlight' and\ config.get_by_tabname('notify_messages', True, self.get_name()): self.state = 'message' - if (not nickname or time) and not txt.startswith('/me '): + if time: + txt = '\x19%(info_col)s}%(txt)s' % {'txt':txt, 'info_col': dump_tuple(get_theme().COLOR_LOG_MSG)} + elif (not nickname or time) and not txt.startswith('/me '): txt = '\x19%(info_col)s}%(txt)s' % {'txt':txt, 'info_col': dump_tuple(get_theme().COLOR_INFORMATION_TEXT)} elif not kwargs.get('highlight'): # TODO args['highlight'] = self.do_highlight(txt, time, nickname) diff --git a/src/text_buffer.py b/src/text_buffer.py index b2915a61..71820b2f 100644 --- a/src/text_buffer.py +++ b/src/text_buffer.py @@ -16,7 +16,7 @@ import collections from datetime import datetime from config import config -from theming import get_theme +from theming import get_theme, dump_tuple message_fields = 'txt nick_color time str_time nickname user identifier highlight me old_message revisions jid' Message = collections.namedtuple('Message', message_fields) @@ -77,6 +77,8 @@ class TextBuffer(object): if txt.startswith('/me '): me = True txt = '\x19%(info_col)s}' % {'info_col': get_theme().COLOR_ME_MESSAGE[0]} + txt[4:] + if history: + txt = txt.replace('\x19o', '\x19o\x19%s}' % dump_tuple(get_theme().COLOR_LOG_MSG)) msg = Message( txt='%s\x19o'%(txt.replace('\t', ' '),), nick_color=nick_color, diff --git a/src/theming.py b/src/theming.py index 2993b8d3..4a578ca7 100644 --- a/src/theming.py +++ b/src/theming.py @@ -267,6 +267,7 @@ class Theme(object): # This is your own nickname COLOR_OWN_NICK = (254, -1) + COLOR_LOG_MSG = (5, -1) # This is for in-tab error messages COLOR_ERROR_MSG = (9, 7, 'b') # Status color diff --git a/src/windows.py b/src/windows.py index cbd661ec..997fb72b 100644 --- a/src/windows.py +++ b/src/windows.py @@ -35,7 +35,7 @@ import core import singleton import collections -from theming import get_theme, to_curses_attr, read_tuple +from theming import get_theme, to_curses_attr, read_tuple, dump_tuple FORMAT_CHAR = '\x19' # These are non-printable chars, so they should never appear in the input, @@ -908,6 +908,11 @@ class TextWin(Win): txt = message.txt if not txt: return [] + if len(message.str_time) > 8: + default_color = (FORMAT_CHAR + dump_tuple(get_theme().COLOR_LOG_MSG) + + '}') + else: + default_color = None ret = [] nick = truncate_nick(message.nickname) offset = 0 @@ -933,7 +938,10 @@ class TextWin(Win): if attrs: prepend = FORMAT_CHAR + FORMAT_CHAR.join(attrs) else: - prepend = '' + if default_color: + prepend = default_color + else: + prepend = '' ret.append(saved) return ret |