Message and complete words can now be colored even if the
take more than one line to be displayed.
This commit is contained in:
parent
8b032a6ece
commit
38cffe43b6
3 changed files with 10 additions and 5 deletions
|
@ -112,7 +112,7 @@ class Room(TextBuffer):
|
|||
if highlight:
|
||||
nick_color = highlight
|
||||
time = time or datetime.now()
|
||||
message = Message(txt=txt, nick_color=nick_color,
|
||||
message = Message(txt='%s\x19o'%(txt,), nick_color=nick_color,
|
||||
time=time, nickname=nickname, user=user)
|
||||
while len(self.messages) > self.messages_nb_limit:
|
||||
self.messages.pop(0)
|
||||
|
|
|
@ -48,7 +48,7 @@ class TextBuffer(object):
|
|||
if not nickname:
|
||||
txt = '\x195%s' % (txt,)
|
||||
nick_color = nick_color
|
||||
msg = Message(txt=txt, nick_color=nick_color,
|
||||
msg = Message(txt='%s\x19o'%(txt,), nick_color=nick_color,
|
||||
time=time or datetime.now(), nickname=nickname, user=None)
|
||||
self.messages.append(msg)
|
||||
while len(self.messages) > self.messages_nb_limit:
|
||||
|
|
|
@ -112,7 +112,6 @@ class Win(object):
|
|||
if y is not None and x is not None:
|
||||
self._win.move(y, x)
|
||||
next_attr_char = string.find('\x19')
|
||||
self._win.attrset(0) # reset all attr
|
||||
while next_attr_char != -1:
|
||||
attr_char = string[next_attr_char+1].lower()
|
||||
if next_attr_char != 0:
|
||||
|
@ -128,7 +127,6 @@ class Win(object):
|
|||
self._win.attron(common.curses_color_pair(int(attr_char)))
|
||||
next_attr_char = string.find('\x19')
|
||||
self.addstr(string)
|
||||
self._win.attrset(0)
|
||||
|
||||
def finish_line(self, color):
|
||||
"""
|
||||
|
@ -608,9 +606,16 @@ class TextWin(Win):
|
|||
else:
|
||||
self.write_time(line.time)
|
||||
self.write_nickname(line.nickname, line.nickname_color)
|
||||
self.write_text(y, line.text_offset, line.text)
|
||||
if y != self.height-1:
|
||||
self.addstr('\n')
|
||||
self._win.attrset(0)
|
||||
for y, line in enumerate(lines):
|
||||
if not line:
|
||||
continue
|
||||
self.write_text(y, line.text_offset, line.text)
|
||||
if y != self.height-1:
|
||||
self.addstr('\n')
|
||||
self._win.attrset(0)
|
||||
self._refresh()
|
||||
|
||||
def write_line_separator(self):
|
||||
|
|
Loading…
Reference in a new issue