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
This commit is contained in:
mathieui 2014-04-07 01:25:30 +02:00
parent 53040305ce
commit 1ce485c6fa
6 changed files with 19 additions and 5 deletions

View file

@ -41,6 +41,7 @@ class DarkTheme(theming.Theme):
COLOR_VERTICAL_TAB_DISCONNECTED = (13, -1)
COLOR_INFORMATION_TEXT = (244, -1)
COLOR_LOG_MSG = (244, -1)
theme = DarkTheme()

View file

@ -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

View file

@ -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)

View file

@ -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,

View file

@ -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

View file

@ -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