[shpy-commit] r2860 - shpy/trunk/dist/shpy

mwh@codespeak.net mwh@codespeak.net
Tue, 20 Jan 2004 16:52:14 +0100 (MET)


Author: mwh
Date: Tue Jan 20 16:52:14 2004
New Revision: 2860

Modified:
   shpy/trunk/dist/shpy/ui_pygame.py
Log:
Do the scrolling in a less ass-backwards fashion.


Modified: shpy/trunk/dist/shpy/ui_pygame.py
==============================================================================
--- shpy/trunk/dist/shpy/ui_pygame.py	(original)
+++ shpy/trunk/dist/shpy/ui_pygame.py	Tue Jan 20 16:52:14 2004
@@ -60,6 +60,7 @@
         pygame.display.flip()
 
     def drawcell(self, screen, cell):
+        self.scroll_cursor_into_view(screen)
         start = -self.vscroll//self.fontheight
         stop = (-self.vscroll + screen.get_size()[1])//self.fontheight + 1
         ypos = self.vscroll + start*self.fontheight
@@ -80,14 +81,17 @@
             c = ' '
         return Rect(self.char_pos(x, y), self.font.size(c))
 
+    def scroll_cursor_into_view(self, screen):
+        ypos = self.vscroll + self.cursor.y * self.fontheight
+        if ypos < 0:
+            screen.fill((255, 255, 255))
+            self.vscroll -= ypos
+        elif ypos + self.fontheight > screen.get_size()[1]:
+            screen.fill((255, 255, 255))
+            self.vscroll -= ypos + self.fontheight - screen.get_size()[1]
+
     def drawcursors(self, screen, cell):
-        othercursors = self.root.users.__dict__.values()
-        try:
-            othercursors.remove(self.cursor)
-        except ValueError:
-            pass
-        othercursors.append(self.cursor)
-        for cursor in othercursors:
+        for cursor in self.root.users.__dict__.values():
             x = cursor.x
             y = cursor.y
             if y >= len(cell.lines):
@@ -97,15 +101,6 @@
                 char = ' '
             charimage = self.font.render(char, 1, (255,255,255), cursor.color)
             screen.blit(charimage, self.char_pos(cell, x, y))
-        ypos = self.vscroll + y * self.fontheight
-        if ypos < 0:
-            screen.fill((255, 255, 255))
-            self.vscroll -= ypos
-            self.drawcell(screen, self.cell)
-        elif ypos + charimage.get_size()[1] > screen.get_size()[1]:
-            screen.fill((255, 255, 255))
-            self.vscroll -= ypos + charimage.get_size()[1] - screen.get_size()[1]
-            self.drawcell(screen, self.cell)
 
     def PRINTABLE_KEY(self, event):
         assert event.unicode