Rev 4902: (vila) Catch SIGWINCH on Unices in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 16 11:39:02 GMT 2009
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 4902 [merge]
revision-id: pqm at pqm.ubuntu.com-20091216113900-alk0tw723aqrbn6x
parent: pqm at pqm.ubuntu.com-20091216010527-nejmuaciaxcutd6q
parent: v.ladeuil+lp at free.fr-20091216105455-c1knt5e61o177gg2
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2009-12-16 11:39:00 +0000
message:
(vila) Catch SIGWINCH on Unices
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
bzrlib/ui/text.py text.py-20051130153916-2e438cffc8afc478
=== modified file 'NEWS'
--- a/NEWS 2009-12-15 19:59:00 +0000
+++ b/NEWS 2009-12-16 10:54:55 +0000
@@ -20,6 +20,9 @@
Bug Fixes
*********
+* Listen to the SIGWINCH signal to update the terminal width.
+ (Vincent Ladeuil, #316357)
+
Improvements
************
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2009-12-14 16:16:05 +0000
+++ b/bzrlib/osutils.py 2009-12-16 10:54:55 +0000
@@ -39,6 +39,7 @@
from shutil import (
rmtree,
)
+import signal
import subprocess
import tempfile
from tempfile import (
@@ -1427,6 +1428,20 @@
_terminal_size = _ioctl_terminal_size
+def _terminal_size_changed(signum, frame):
+ """Set COLUMNS upon receiving a SIGnal for WINdow size CHange."""
+ width, height = _terminal_size(None, None)
+ if width is not None:
+ os.environ['COLUMNS'] = str(width)
+
+if sys.platform == 'win32':
+ # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from ReadConsoleInput but
+ # I've no idea how to plug that in the current design -- vila 20091216
+ pass
+else:
+ signal.signal(signal.SIGWINCH, _terminal_size_changed)
+
+
def supports_executable():
return sys.platform != "win32"
=== modified file 'bzrlib/ui/text.py'
--- a/bzrlib/ui/text.py 2009-12-14 06:05:30 +0000
+++ b/bzrlib/ui/text.py 2009-12-16 10:54:55 +0000
@@ -248,9 +248,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
@@ -267,9 +264,11 @@
def _show_line(self, s):
# sys.stderr.write("progress %r\n" % s)
- 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