Stub in curpos for offscreen items
authorJack Miller <jack@codezen.org>
Fri, 30 Jan 2015 22:07:41 +0000 (16:07 -0600)
committerJack Miller <jack@codezen.org>
Fri, 30 Jan 2015 22:07:41 +0000 (16:07 -0600)
This should quash the curpos exceptions, and possibly a hard lock
related to them. Stub them in as self.height, which is short hand for
"off screen down" as it should cause a scroll.

Calculating the actual value would cause the redraw function to scale
linearly with number of items instead of (the much smaller and usually
constant) value of the screen size.

canto_curses/taglist.py

index 7343517..4b16cef 100644 (file)
@@ -1195,6 +1195,14 @@ class TagList(GuiBase):
             obj.lines(self.width)
             obj.curpos = curpos
 
+            # If we're outside of the render window, then skip the actual
+            # rendering, but stub in curpos.
+
+            if w_offset >= self.height:
+                obj.curpos = self.height
+                obj = obj.next_obj
+                continue
+
             # Copy item into window
             w_offset, curpos = self._partial_render(obj, w_offset, curpos)
 
@@ -1232,9 +1240,6 @@ class TagList(GuiBase):
 
                 rendered_header = True
 
-            if w_offset >= self.height:
-                break
-
             obj = obj.next_obj
 
         self.callbacks["refresh"]()