diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-06-30 10:21:16 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-06-30 10:21:16 +0000 |
commit | dc39cdab50f8fc2df9683bb26a3eafc3a3675f56 (patch) | |
tree | 096f89297b365b54ea1ae9398a85b4f84ed805ab /src | |
parent | cf88579ec74a90c6dfb1f456800119a757f936b7 (diff) | |
download | poezio-dc39cdab50f8fc2df9683bb26a3eafc3a3675f56.tar.gz poezio-dc39cdab50f8fc2df9683bb26a3eafc3a3675f56.tar.bz2 poezio-dc39cdab50f8fc2df9683bb26a3eafc3a3675f56.tar.xz poezio-dc39cdab50f8fc2df9683bb26a3eafc3a3675f56.zip |
break line on spaces if possible. Fixed #1541
Diffstat (limited to 'src')
-rw-r--r-- | src/window.py | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/window.py b/src/window.py index c62dd869..87014cfd 100644 --- a/src/window.py +++ b/src/window.py @@ -210,11 +210,21 @@ class TextWin(Win): if nick: offset += len(nick) + 2 # + nick + spaces length first = True + this_line_was_broken_by_space = False while txt != '': if txt[:self.width-offset].find('\n') != -1: limit = txt[:self.width-offset].find('\n') else: - limit = self.width-offset-1 + # break between words if possible + if len(txt) >= self.width: + limit = txt[:self.width-offset-1].rfind(' ') + this_line_was_broken_by_space = True + if limit <= 0: + limit = self.width-offset-1 + this_line_was_broken_by_space = False + else: + limit = self.width-offset-1 + this_line_was_broken_by_space = False color = message.user.color if message.user else None if not first: nick = None @@ -223,7 +233,10 @@ class TextWin(Win): txt[:limit], message.color, offset) lines.append(l) - txt = txt[limit:] + if this_line_was_broken_by_space: + txt = txt[limit+1:] # jump the space at the start of the line + else: + txt = txt[limit:] if txt.startswith('\n'): txt = txt[1:] first = False |