Rev 4761: catch SIGWINCH, but that means soem IO can be interrupted and the code in file:///home/vila/src/bzr/bugs/316357-SIGWINCH/
Vincent Ladeuil
v.ladeuil+lp at free.fr
Wed Dec 9 14:24:08 GMT 2009
At file:///home/vila/src/bzr/bugs/316357-SIGWINCH/
------------------------------------------------------------
revno: 4761
revision-id: v.ladeuil+lp at free.fr-20091209142407-qqdaebna2fyz9vam
parent: v.ladeuil+lp at free.fr-20091209103104-3mu4zqvl6myzq4cd
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: 316357-SIGWINCH
timestamp: Wed 2009-12-09 15:24:07 +0100
message:
catch SIGWINCH, but that means soem IO can be interrupted and the code
base is not ready for that.
* bzrlib/ui/text.py:
(TextProgressView._show_line): Refresh width in case a SIGWINCH
was received.
* bzrlib/osutils.py:
(_terminal_size_changed): Trivial implementation
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2009-12-09 10:31:04 +0000
+++ b/bzrlib/osutils.py 2009-12-09 14:24:07 +0000
@@ -19,6 +19,7 @@
import stat
from stat import (S_ISREG, S_ISDIR, S_ISLNK, ST_MODE, ST_SIZE,
S_ISCHR, S_ISBLK, S_ISFIFO, S_ISSOCK)
+import signal
import sys
import time
import warnings
@@ -1398,7 +1399,7 @@
import struct, fcntl, termios
s = struct.pack('HHHH', 0, 0, 0, 0)
x = fcntl.ioctl(1, termios.TIOCGWINSZ, s)
- width, height = struct.unpack('HHHH', x)[0:2]
+ height, width = struct.unpack('HHHH', x)[0:2]
except (IOError, AttributeError):
pass
return width, height
@@ -1418,6 +1419,14 @@
_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)
+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-07 10:38:09 +0000
+++ b/bzrlib/ui/text.py 2009-12-09 14:24:07 +0000
@@ -234,6 +234,7 @@
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)
More information about the bazaar-commits
mailing list