From: Jeremy Katz Subject: [PATCH] Fix editing of long lines in pygrub Date: Tue, 27 Mar 2007 15:45:29 -0400 Message-ID: <1175024730.18922.27.camel@erebor.boston.redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-oaNFPZGuwk0lfHBhGwc2" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --=-oaNFPZGuwk0lfHBhGwc2 Content-Type: text/plain Content-Transfer-Encoding: 7bit Editing long lines in pygrub interactively could lead to tracebacks. Attached patch fixes things. Signed-off-by: Jeremy Katz Jeremy --=-oaNFPZGuwk0lfHBhGwc2 Content-Disposition: attachment; filename=pygrub-line-length.patch Content-Type: text/x-patch; name=pygrub-line-length.patch; charset=UTF-8 Content-Transfer-Encoding: 7bit diff -r 10fcea8f51cd tools/pygrub/src/pygrub --- a/tools/pygrub/src/pygrub Mon Mar 26 14:10:19 2007 +0100 +++ b/tools/pygrub/src/pygrub Tue Mar 27 15:40:08 2007 -0400 @@ -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) --=-oaNFPZGuwk0lfHBhGwc2 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --=-oaNFPZGuwk0lfHBhGwc2--