fix an infinie loop on empty line, and the bug with the history message said...

fix an infinie loop on empty line, and the bug with the history message said by a nickname not present anymore
parent 981e12a6
......@@ -321,9 +321,9 @@ Avail: Sets your availability to available and (optional) sets your status
"""
Display the error on the room window
"""
# if not error:
# return
room = self.get_room_by_name(room)
if not error:
return
code = error.getAttr('code')
typ = error.getAttr('type')
body = error.getTag('text').getData()
......
......@@ -70,8 +70,6 @@ class Line(object):
Line(None, None, None, "http://blablablabla", 0, 23)
"""
def __init__(self, nickname, nickname_color, time, text, text_color, text_offset):
from common import debug
# debug("Line: %s, %s, %s '%s', %s, %s\n" % (nickname, nickname_color, str(time), text, text_color, text_offset))
self.nickname = nickname
self.nickname_color = nickname_color
self.time = time
......
......@@ -184,6 +184,7 @@ class TextWin(Win):
for message in messages:
txt = message.txt
offset = 11 # length of the time
debug(str(message.nickname) + ' : '+message.txt + '\n')
if message.nickname and len(message.nickname) >= 30:
nick = message.nickname[:30]+u'…'
else:
......@@ -198,17 +199,14 @@ class TextWin(Win):
# debug("=================="+str(limit))
else:
limit = self.width-offset-1
if first and message.user:
line = Line(nick, message.user.color,
message.time,
txt[:limit], message.color,
offset)
else:
line = Line(None, None,
message.time,
txt[:limit], message.color,
offset)
lines.append(line)
if limit == 0:
break
color = message.user.color if message.user else None
l = Line(nick, color,
message.time,
txt[:limit], message.color,
offset)
lines.append(l)
txt = txt[limit:]
first = False
return lines[-len(messages):]# return only the needed number of lines
......@@ -271,9 +269,11 @@ class TextWin(Win):
Write the nickname, using the user's color
and return the number of written characters
"""
self.win.attron(curses.color_pair(color))
if color:
self.win.attron(curses.color_pair(color))
self.win.addstr(nickname)
self.win.attroff(curses.color_pair(color))
if color:
self.win.attroff(curses.color_pair(color))
self.win.addnstr("> ", 2)
def write_time(self, time):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment