Use get_term_size() to adjust to current terminal width. Thanks to Dror Levin
authorZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:43:21 +0000 (18:43 -0000)
committerZac Medico <zmedico@gentoo.org>
Fri, 29 Jan 2010 18:43:21 +0000 (18:43 -0000)
<spatz@g.0> for the initial patch. (trunk r15156)

svn path=/main/branches/2.1.7/; revision=15224

pym/_emerge/JobStatusDisplay.py

index cfc0bfa91ce6419f067741ce15ff5fc002616403..dfc766d26df32420edcc5d34da5aa5b1a3139ed7 100644 (file)
@@ -22,7 +22,6 @@ if sys.hexversion >= 0x3000000:
 class JobStatusDisplay(object):
 
        _bound_properties = ("curval", "failed", "running")
-       _jobs_column_width = 48
 
        # Don't update the display unless at least this much
        # time has passed, in units of seconds.
@@ -48,7 +47,12 @@ class JobStatusDisplay(object):
                object.__setattr__(self, "_changed", False)
                object.__setattr__(self, "_displayed", False)
                object.__setattr__(self, "_last_display_time", 0)
-               object.__setattr__(self, "width", 80)
+
+               width = portage.output.get_term_size()[1]
+               if width <= 0 or width > 80:
+                       width = 80
+               object.__setattr__(self, "width", width)
+               object.__setattr__(self, "_jobs_column_width", width - 32)
                self.reset()
 
                isatty = hasattr(self.out, "isatty") and self.out.isatty()