diff options
author | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-12-15 15:40:43 +0000 |
---|---|---|
committer | louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13 <louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13> | 2010-12-15 15:40:43 +0000 |
commit | 0db8bf7d461e1d618ae7efb2f00dc2d99ddf7ca3 (patch) | |
tree | 38cf0930bb62a1b26dde8e24644694e94a73f234 /src/room.py | |
parent | 24d6894b64455ca1135a8b43ddf4ddbf94365a96 (diff) | |
download | poezio-0db8bf7d461e1d618ae7efb2f00dc2d99ddf7ca3.tar.gz poezio-0db8bf7d461e1d618ae7efb2f00dc2d99ddf7ca3.tar.bz2 poezio-0db8bf7d461e1d618ae7efb2f00dc2d99ddf7ca3.tar.xz poezio-0db8bf7d461e1d618ae7efb2f00dc2d99ddf7ca3.zip |
HUGE performance improvement on refresh. fixed #1855
Diffstat (limited to 'src/room.py')
-rw-r--r-- | src/room.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/room.py b/src/room.py index 62ece926..2fe7a188 100644 --- a/src/room.py +++ b/src/room.py @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with Poezio. If not, see <http://www.gnu.org/licenses/>. -from text_buffer import TextBuffer +from text_buffer import TextBuffer, MESSAGE_NB_LIMIT from datetime import datetime from random import randrange from config import config @@ -25,8 +25,6 @@ import common import theme class Room(TextBuffer): - """ - """ def __init__(self, name, nick): TextBuffer.__init__(self) self.name = name @@ -118,6 +116,13 @@ class Room(TextBuffer): if time: # History messages are colored to be distinguished color = theme.COLOR_INFORMATION_TEXT time = time if time is not None else datetime.now() - if self.pos: # avoid scrolling of one line when one line is received - self.pos += 1 - self.messages.append(Message(txt, time, nickname, user, color, colorized)) + message = Message(txt, time, nickname, user, color, colorized) + while len(self.messages) > MESSAGE_NB_LIMIT: + self.messages.pop(0) + self.messages.append(message) + for window in self.windows: # make the associated windows + # build the lines from the new message + nb = window.build_new_message(message) + if window.pos != 0: + window.scroll_up(nb) + |