Mercurial > public > mercurial-scm > hg-stable
diff mercurial/posix.py @ 11011:648130161e4d
Merge with crew-stable
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Mon, 26 Apr 2010 22:42:46 +0200 |
parents | ab3782458827 18e81d42ee5c |
children | 99eee847beaa |
line wrap: on
line diff
--- a/mercurial/posix.py Mon Apr 26 21:35:09 2010 +0200 +++ b/mercurial/posix.py Mon Apr 26 22:42:46 2010 +0200 @@ -265,3 +265,27 @@ def gethgcmd(): return sys.argv[:1] + +def termwidth_(): + try: + import termios, array, fcntl + for dev in (sys.stderr, sys.stdout, sys.stdin): + try: + try: + fd = dev.fileno() + except AttributeError: + continue + if not os.isatty(fd): + continue + arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) + return array.array('h', arri)[1] + except ValueError: + pass + except IOError, e: + if e[0] == errno.EINVAL: + pass + else: + raise + except ImportError: + pass + return 80