From d364c1f4f3eae87354993b5bfdb952652ee9b44f Mon Sep 17 00:00:00 2001 From: "louiz@4325f9fc-e183-4c21-96ce-0ab188b42d13" Date: Wed, 4 Aug 2010 00:48:50 +0000 Subject: fix the scroll again. The scroll size is now a page - 1 and it handles the multiline message perfectly --- src/gui.py | 4 ++-- src/room.py | 10 ++++------ src/window.py | 4 ++++ 3 files changed, 10 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gui.py b/src/gui.py index 0363026e..a1b1a117 100644 --- a/src/gui.py +++ b/src/gui.py @@ -321,11 +321,11 @@ class Gui(object): self.refresh_window() def scroll_page_down(self, args=None): - self.current_room().scroll_down() + self.current_room().scroll_down(self.window.text_win.height-1) self.refresh_window() def scroll_page_up(self, args=None): - self.current_room().scroll_up(self.window.size) + self.current_room().scroll_up(self.window.text_win.height-1) self.refresh_window() def room_error(self, room, error, msg): diff --git a/src/room.py b/src/room.py index b7cb8ed3..0863b209 100644 --- a/src/room.py +++ b/src/room.py @@ -42,13 +42,11 @@ class Room(object): self.window = window self.pos = 0 # offset - def scroll_up(self, y_x, dist=14): - y, x = y_x - if len(self.messages) <= y: - return + def scroll_up(self, dist=14): + # The pos can grow a lot over the top of the number of + # available lines, it will be fixed on the next refresh of the + # screen anyway self.pos += dist - if self.pos + y >= len(self.messages): - self.pos = len(self.messages) - y+3 def scroll_down(self, dist=14): self.pos -= dist diff --git a/src/window.py b/src/window.py index f50d8c08..fd3179ac 100644 --- a/src/window.py +++ b/src/window.py @@ -264,6 +264,10 @@ class TextWin(Win): # else: # messages = room.messages[-self.height:] lines = self.build_lines_from_messages(room.messages) + if room.pos + self.height > len(lines): + room.pos = len(lines) - self.height + if room.pos < 0: + room.pos = 0 if room.pos != 0: lines = lines[-self.height-room.pos:-room.pos] else: -- cgit v1.2.3