From 575e47390093480f4b90e795bb2930fa6d85bb56 Mon Sep 17 00:00:00 2001 From: "Pawel Hajdan, Jr" Date: Thu, 3 Nov 2011 12:00:23 +0100 Subject: Fix bugs resulting in ncurses-induced "crashes". --- bugzilla-viewer.py | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/bugzilla-viewer.py b/bugzilla-viewer.py index 48b253e..45584a5 100755 --- a/bugzilla-viewer.py +++ b/bugzilla-viewer.py @@ -160,12 +160,14 @@ class MainWindow: def init_screen(self): (self.height, self.width) = self.screen.getmaxyx() + self.bugs_pad_width = self.width / 3 - 1 + self.contents_pad_width = self.width - self.bugs_pad_width - 1 if self.height < 12 or self.width < 80: raise TermTooSmall() self.screen.border() - self.screen.vline(1, self.width / 3, curses.ACS_VLINE, self.height - 2) + self.screen.vline(1, self.bugs_pad_width + 1, curses.ACS_VLINE, self.height - 2) self.screen.refresh() self.fill_bugs_pad() @@ -208,58 +210,56 @@ class MainWindow: self.bugs_pad.refresh( pos, 0, 1, 1, - self.height - 2, self.width / 3 - 1) + self.height - 2, self.bugs_pad_width) def fill_contents_pad(self): - width = 2 * self.width / 3 - bug = self.bugs[self.bugs_pad_pos] output = [] - output += textwrap.wrap(bug.summary(), width=width-2) - output.append("-" * (width - 2)) + output += textwrap.wrap(bug.summary(), width=self.contents_pad_width-2) + output.append("-" * (self.contents_pad_width - 2)) cpvs = bug.cpvs() if cpvs: - output += textwrap.wrap("Found package cpvs:", width=width-2) + output += textwrap.wrap("Found package cpvs:", width=self.contents_pad_width-2) for cpv in cpvs: - output += textwrap.wrap(cpv, width=width-2) - output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=width-2) - output.append("-" * (width - 2)) + output += textwrap.wrap(cpv, width=self.contents_pad_width-2) + output += textwrap.wrap("Press 'a' to add them to the stabilization queue.", width=self.contents_pad_width-2) + output.append("-" * (self.contents_pad_width - 2)) deps = [self.bug_for_id(dep_id) for dep_id in bug.depends_on()] if deps: - output += textwrap.wrap("Depends on:", width=width-2) + output += textwrap.wrap("Depends on:", width=self.contents_pad_width-2) for dep in deps: desc = "%d %s %s" % (dep.id_number(), dep.status(), dep.summary()) - output += textwrap.wrap(desc, width=width-2) - output.append("-" * (width - 2)) + output += textwrap.wrap(desc, width=self.contents_pad_width-2) + output.append("-" * (self.contents_pad_width - 2)) related = self.related_bugs[bug.id_number()] if related: - output += textwrap.wrap("Related bugs:", width=width-2) + output += textwrap.wrap("Related bugs:", width=self.contents_pad_width-2) for related_bug in related: if str(related_bug['bugid']) == str(bug.id_number()): continue desc = related_bug['bugid'] + " " + related_bug['desc'] - output += textwrap.wrap(desc, width=width-2) - output.append("-" * (width - 2)) + output += textwrap.wrap(desc, width=self.contents_pad_width-2) + output.append("-" * (self.contents_pad_width - 2)) if bug.id_number() in repoman_dict and repoman_dict[bug.id_number()]: - output += textwrap.wrap("Repoman output:", width=width-2) + output += textwrap.wrap("Repoman output:", width=self.contents_pad_width-2) lines = repoman_dict[bug.id_number()].split("\n") for line in lines: - output += textwrap.wrap(line, width=width-2) - output.append("-" * (width - 2)) + output += textwrap.wrap(line, width=self.contents_pad_width-2) + output.append("-" * (self.contents_pad_width - 2)) for comment in bug.comments(): for line in comment.split("\n"): - output += textwrap.wrap(line, width=width-2) - output.append("-" * (width - 2)) + output += textwrap.wrap(line, width=self.contents_pad_width-2) + output.append("-" * (self.contents_pad_width - 2)) self.contents_pad_length = len(output) - self.contents_pad = curses.newpad(max(self.contents_pad_length, self.height), width) + self.contents_pad = curses.newpad(max(self.contents_pad_length, self.height), self.contents_pad_width) self.contents_pad.erase() self.contents_pad_pos = 0 @@ -280,7 +280,7 @@ class MainWindow: def refresh_contents_pad(self): self.contents_pad.refresh( self.contents_pad_pos, 0, - 1, self.width / 3 + 1, + 1, self.bugs_pad_width + 2, self.height - 2, self.width - 2) self.screen.refresh() -- cgit v1.2.3-65-gdbad