Rev 4762: Cleanup and NEWS entry. in file:///home/vila/src/bzr/bugs/316357-SIGWINCH/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Dec 10 12:31:39 GMT 2009


At file:///home/vila/src/bzr/bugs/316357-SIGWINCH/

------------------------------------------------------------
revno: 4762
revision-id: v.ladeuil+lp at free.fr-20091210123139-n8mgml3nid1the59
parent: v.ladeuil+lp at free.fr-20091209142407-qqdaebna2fyz9vam
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 316357-SIGWINCH
timestamp: Thu 2009-12-10 13:31:39 +0100
message:
  Cleanup and NEWS entry.
  
  * bzrlib/ui/text.py:
  (TextProgressView._show_line): Stop caching terminal width.
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2009-12-09 10:31:04 +0000
+++ b/NEWS	2009-12-10 12:31:39 +0000
@@ -61,6 +61,9 @@
 
 * Interactive merge doesn't leave branch locks behind.  (Aaron Bentley)
 
+* Listen to the SIGWINCH signal to update the terminal width.
+  (Vincent Ladeuil, #316357)
+
 * Lots of bugfixes for the test suite on Windows. We should once again
   have a test suite with no failures on Windows. (John Arbash Meinel)
 

=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py	2009-12-09 14:24:07 +0000
+++ b/bzrlib/ui/text.py	2009-12-10 12:31:39 +0000
@@ -218,9 +218,6 @@
         self._term_file = term_file
         # true when there's output on the screen we may need to clear
         self._have_output = False
-        # XXX: We could listen for SIGWINCH and update the terminal width...
-        # https://launchpad.net/bugs/316357
-        self._width = osutils.terminal_width()
         self._last_transport_msg = ''
         self._spin_pos = 0
         # time we last repainted the screen
@@ -234,10 +231,11 @@
 
     def _show_line(self, s):
         # sys.stderr.write("progress %r\n" % s)
-        self._width = osutils.terminal_width()
-        if self._width is not None:
-            n = self._width - 1
-            s = '%-*.*s' % (n, n, s)
+        width = osutils.terminal_width()
+        if width is not None:
+            # we need one extra space for terminals that wrap on last char
+            width = width - 1
+            s = '%-*.*s' % (width, width, s)
         self._term_file.write('\r' + s + '\r')
 
     def clear(self):



More information about the bazaar-commits mailing list