fix an infinie loop on empty line, and the bug with the history message said by a nickname not present anymore

This commit is contained in:
louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 2010-06-12 22:33:01 +00:00
parent 981e12a669
commit 3a0ff72c7a
3 changed files with 15 additions and 17 deletions

View file

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

View file

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

View file

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