From 40e45c56ba122f807aeb1c43517919d3ee23de17 Mon Sep 17 00:00:00 2001 From: mfrasca <> Date: Mon, 16 Oct 2006 13:12:13 +0000 Subject: [PATCH] 1578113: trailing black in text line rewritten the _scrollAndDisplay method. --- examples/pywmgeneric.py | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/examples/pywmgeneric.py b/examples/pywmgeneric.py index 530c06e..c78f8d5 100644 --- a/examples/pywmgeneric.py +++ b/examples/pywmgeneric.py @@ -141,7 +141,7 @@ height = 64 xOffset = 4 yOffset = 4 -maxChars = 9 +maxChars = 13 defaultConfigFile = '~/.pywmgenericrc' defaultRGBFiles = ('/usr/share/X11/rgb.txt', '/usr/X11R6/lib/X11/rgb.txt') @@ -191,6 +191,7 @@ class Entry: self._display = display self._scrollText = scrollText + self._glue = ' ... ' self._scrollPos = 0 self._tickCount = 0L @@ -331,23 +332,16 @@ class Entry: When reaching the end, paint number of spaces before scrolling in the same line again from the right. """ - if self._scrollPos >= \ - len(self._displayLine) + (maxChars - 4): - self._scrollPos = 0 - self.displayText(self._displayLine) - elif self._scrollPos >= len(self._displayLine) - 3: - self._scrollPos += 1 - disp = self._displayLine[self._scrollPos:] + \ - ' ' * (maxChars - 3) - diff = self._scrollPos - len(self._displayLine) - if diff > 0: - disp = disp[diff:] - disp += self._displayLine - self.displayText(disp) - else: - self._scrollPos += 1 - self.displayText( - self._displayLine[self._scrollPos:]) + + # increase the amount of scrolled chars by one, modulo the lenght. + # take the line, append to it some glue and a copy of the line + # again, drop as many characters as the updated scrollPos, display + # the resulting text. + self._scrollPos += 1 + self._scrollPos %= len(self._displayLine) + len(self._glue) + disp = self._displayLine + self._glue + self._displayLine + disp = disp[self._scrollPos:] + self.displayText(disp) def tick1(self): """Do things that should be done often.