[shpy-commit] r2837 - shpy/trunk/dist/shpy
mwh@codespeak.net
mwh@codespeak.net
Mon, 19 Jan 2004 17:01:20 +0100 (MET)
Author: mwh
Date: Mon Jan 19 17:01:20 2004
New Revision: 2837
Modified:
shpy/trunk/dist/shpy/ui_pygame.py
Log:
Braincrushingly simple and inefficient scrolling support.
Modified: shpy/trunk/dist/shpy/ui_pygame.py
==============================================================================
--- shpy/trunk/dist/shpy/ui_pygame.py (original)
+++ shpy/trunk/dist/shpy/ui_pygame.py Mon Jan 19 17:01:20 2004
@@ -19,9 +19,10 @@
self.lines = text.split('\n')
assert self.lines
self.cursor = None
+ self.vscroll = 0
def draw(self, screen, font):
- ypos = 0
+ ypos = self.vscroll
yposlist = []
for line in self.lines:
yposlist.append(ypos)
@@ -41,6 +42,14 @@
ypos = yposlist[y]
char = line[x:x+1] or ' '
charimage = font.render(char, 1, (255,255,255), (40,0,0))
+ if ypos < 0:
+ screen.fill((255, 255, 255))
+ self.vscroll -= ypos
+ self.draw(screen, font)
+ 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.draw(screen, font)
screen.blit(charimage, (xpos, ypos))