/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: Andrew Bennetts
  • Date: 2010-05-26 02:19:33 UTC
  • mto: (4797.43.13 2.1)
  • mto: This revision was merged to the branch mainline in revision 5264.
  • Revision ID: andrew.bennetts@canonical.com-20100526021933-8ygb8kq2bczwh44c
Remove the SIGWINCH signal handler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1416
1416
        pass
1417
1417
 
1418
1418
    isatty = getattr(sys.stdout, 'isatty', None)
1419
 
    if  isatty is None or not isatty():
 
1419
    if isatty is None or not isatty():
1420
1420
        # Don't guess, setting BZR_COLUMNS is the recommended way to override.
1421
1421
        return None
1422
1422
 
1423
 
    # If COLUMNS is set, take it, the terminal knows better (even inside a
1424
 
    # given terminal, the application can decide to set COLUMNS to a lower
1425
 
    # value (splitted screen) or a bigger value (scroll bars))
 
1423
    # If the OS knows how wide the terminal is, use that.
 
1424
    width, height = _terminal_size(None, None)
 
1425
    if width is not None and width > 0:
 
1426
        return width
 
1427
 
 
1428
    # If COLUMNS is set, use it.
1426
1429
    try:
1427
1430
        return int(os.environ['COLUMNS'])
1428
1431
    except (KeyError, ValueError):
1429
1432
        pass
1430
1433
 
1431
 
    width, height = _terminal_size(None, None)
1432
 
    if width <= 0:
1433
 
        # Consider invalid values as meaning no width
1434
 
        return None
1435
 
 
1436
 
    return width
 
1434
    # Return None if the width could not be determined.
 
1435
    return None
1437
1436
 
1438
1437
 
1439
1438
def _win32_terminal_size(width, height):
1466
1465
    _terminal_size = _ioctl_terminal_size
1467
1466
 
1468
1467
 
1469
 
def _terminal_size_changed(signum, frame):
1470
 
    """Set COLUMNS upon receiving a SIGnal for WINdow size CHange."""
1471
 
    width, height = _terminal_size(None, None)
1472
 
    if width is not None:
1473
 
        os.environ['COLUMNS'] = str(width)
1474
 
 
1475
 
 
1476
 
_registered_sigwinch = False
1477
 
 
1478
 
def watch_sigwinch():
1479
 
    """Register for SIGWINCH, once and only once."""
1480
 
    global _registered_sigwinch
1481
 
    if not _registered_sigwinch:
1482
 
        if sys.platform == 'win32':
1483
 
            # Martin (gz) mentioned WINDOW_BUFFER_SIZE_RECORD from
1484
 
            # ReadConsoleInput but I've no idea how to plug that in
1485
 
            # the current design -- vila 20091216
1486
 
            pass
1487
 
        else:
1488
 
            set_signal_handler(signal.SIGWINCH, _terminal_size_changed)
1489
 
        _registered_sigwinch = True
1490
 
 
1491
 
 
1492
1468
def supports_executable():
1493
1469
    return sys.platform != "win32"
1494
1470