equal
deleted
inserted
replaced
40 if sys.platform == 'plan9': |
40 if sys.platform == 'plan9': |
41 return [encoding.environ['home'] + '/lib/hgrc'] |
41 return [encoding.environ['home'] + '/lib/hgrc'] |
42 else: |
42 else: |
43 return [os.path.expanduser('~/.hgrc')] |
43 return [os.path.expanduser('~/.hgrc')] |
44 |
44 |
45 def termwidth(ui): |
45 def termsize(ui): |
46 try: |
46 try: |
47 import termios |
47 import termios |
48 TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449) |
48 TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449) |
49 except (AttributeError, ImportError): |
49 except (AttributeError, ImportError): |
50 return 80 |
50 return 80, 24 |
51 |
51 |
52 for dev in (ui.ferr, ui.fout, ui.fin): |
52 for dev in (ui.ferr, ui.fout, ui.fin): |
53 try: |
53 try: |
54 try: |
54 try: |
55 fd = dev.fileno() |
55 fd = dev.fileno() |
56 except AttributeError: |
56 except AttributeError: |
57 continue |
57 continue |
58 if not os.isatty(fd): |
58 if not os.isatty(fd): |
59 continue |
59 continue |
60 arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8) |
60 arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8) |
61 width = array.array('h', arri)[1] |
61 height, width = array.array('h', arri)[:2] |
62 if width > 0: |
62 if width > 0 and height > 0: |
63 return width |
63 return width, height |
64 except ValueError: |
64 except ValueError: |
65 pass |
65 pass |
66 except IOError as e: |
66 except IOError as e: |
67 if e[0] == errno.EINVAL: |
67 if e[0] == errno.EINVAL: |
68 pass |
68 pass |
69 else: |
69 else: |
70 raise |
70 raise |
71 return 80 |
71 return 80, 24 |