From: Zac Medico Date: Sun, 27 May 2007 12:39:35 +0000 (-0000) Subject: Add SIGWINCH support so that the progress bar is resized if the xterm is resized. X-Git-Tag: v2.2_pre1~1358 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=99e5a83582eff3900cb74fec86a1abd12ef96bad;p=portage.git Add SIGWINCH support so that the progress bar is resized if the xterm is resized. svn path=/main/trunk/; revision=6640 --- diff --git a/bin/emaint b/bin/emaint index c44bbe85a..0628db371 100755 --- a/bin/emaint +++ b/bin/emaint @@ -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)