Skip to contentSkip to conversation

Fix editing of long lines in pygrub

PATCH New Jeremy Katz 1 participant 1 message Mar 27, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix editing of long lines in pygrub

Editing long lines in pygrub interactively could lead to tracebacks. Attached patch fixes things.

Jeremy

tools/pygrub/src/pygrub +7 -10
diff -r 10fcea8f51cd tools/pygrub/src/pygrub
@@ -125,16 +125,13 @@ class GrubLineEditor(curses.textpad.Text
         is that we can handle lines longer than the window."""
 
         self.win.clear()
-        if self.pos > 70:
-            if self.pos > 130:
-                off = 120
-            else:
-                off = 55
-            l = [ "<" ] + self.line[off:]
-            p = self.pos - off
-        else:
-            l = self.line[:70]
-            p = self.pos
+        p = self.pos
+        off = 0
+        while p > 70:
+            p -= 55
+            off += 55
+
+        l = self.line[off:off+70]
         self.win.addstr(0, 0, string.join(l, ("")))
         if self.pos > 70:
             self.win.addch(0, 0, curses.ACS_LARROW)

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel