don't crash on very big nickname
This commit is contained in:
parent
94fcfd0792
commit
52c8cdb5ce
1 changed files with 8 additions and 4 deletions
|
@ -187,8 +187,12 @@ class TextWin(Win):
|
||||||
for message in messages:
|
for message in messages:
|
||||||
txt = message.txt
|
txt = message.txt
|
||||||
offset = 11 # length of the time
|
offset = 11 # length of the time
|
||||||
if message.nickname:
|
if message.nickname and len(message.nickname) >= 30:
|
||||||
offset += len(message.nickname) + 2 # + nick + spaces length
|
nick = message.nickname[:30]+u'…'
|
||||||
|
else:
|
||||||
|
nick = message.nickname
|
||||||
|
if nick:
|
||||||
|
offset += len(nick) + 2 # + nick + spaces length
|
||||||
first = True
|
first = True
|
||||||
while txt != '':
|
while txt != '':
|
||||||
# debug(txt)
|
# debug(txt)
|
||||||
|
@ -198,7 +202,7 @@ class TextWin(Win):
|
||||||
else:
|
else:
|
||||||
limit = self.width-offset-1
|
limit = self.width-offset-1
|
||||||
if first and message.user:
|
if first and message.user:
|
||||||
line = Line(message.nickname, message.user.color,
|
line = Line(nick, message.user.color,
|
||||||
message.time,
|
message.time,
|
||||||
txt[:limit], message.color,
|
txt[:limit], message.color,
|
||||||
offset)
|
offset)
|
||||||
|
@ -651,7 +655,7 @@ class Window(object):
|
||||||
Resize the whole tabe. i.e. all its sub-windows
|
Resize the whole tabe. i.e. all its sub-windows
|
||||||
"""
|
"""
|
||||||
self.size = (self.height, self.width) = stdscr.getmaxyx()
|
self.size = (self.height, self.width) = stdscr.getmaxyx()
|
||||||
if self.height < 10 or self.width < 60:
|
if self.height < 10 or self.width < 50:
|
||||||
visible = False
|
visible = False
|
||||||
else:
|
else:
|
||||||
visible = True
|
visible = True
|
||||||
|
|
Loading…
Reference in a new issue