Add SIGWINCH support so that the progress bar is resized if the xterm is resized.
authorZac Medico <zmedico@gentoo.org>
Sun, 27 May 2007 12:39:35 +0000 (12:39 -0000)
committerZac Medico <zmedico@gentoo.org>
Sun, 27 May 2007 12:39:35 +0000 (12:39 -0000)
svn path=/main/trunk/; revision=6640

bin/emaint

index c44bbe85afd38f989d16baef204c643bbbc41983..0628db3715dd69d67aae835c3773630608045250 100755 (executable)
@@ -1,6 +1,6 @@
 #!/usr/bin/python -O
 
-import sys, os, time
+import sys, os, time, signal
 from optparse import OptionParser, OptionValueError
 if not hasattr(__builtins__, "set"):
        from sets import Set as set
@@ -218,13 +218,18 @@ def emaint_main(myargv):
                        progressBar = portage.output.TermProgressBar()
                        progressHandler = ProgressHandler()
                        def display():
-                               progressBar.set(progressHandler.maxval, progressHandler.curval)
+                               progressBar.set(progressHandler.curval, progressHandler.maxval)
                        progressHandler.display = display
+                       def sigwinch_handler(signum, frame):
+                               lines, progressBar.term_columns = \
+                                       portage.output.get_term_size()
+                       signal.signal(signal.SIGWINCH, sigwinch_handler)
                result = getattr(inst, func)(onProgress=progressHandler.onProgress)
                if isatty:
                        # make sure the final progress is displayed
                        progressHandler.display()
                        print
+                       signal.signal(signal.SIGWINCH, signal.SIG_DFL)
                if result:
                        print
                        print "\n".join(result)