Show More
@@ -1,5 +1,6 b'' | |||||
1 | from __future__ import absolute_import |
|
1 | from __future__ import absolute_import | |
2 |
|
2 | |||
|
3 | import array | |||
3 | import errno |
|
4 | import errno | |
4 | import fcntl |
|
5 | import fcntl | |
5 | import os |
|
6 | import os | |
@@ -43,8 +44,11 b' def userrcpath():' | |||||
43 |
|
44 | |||
44 | def termwidth(ui): |
|
45 | def termwidth(ui): | |
45 | try: |
|
46 | try: | |
46 | import array |
|
|||
47 | import termios |
|
47 | import termios | |
|
48 | TIOCGWINSZ = termios.TIOCGWINSZ # unavailable on IRIX (issue3449) | |||
|
49 | except (AttributeError, ImportError): | |||
|
50 | return 80 | |||
|
51 | if True: | |||
48 | for dev in (ui.ferr, ui.fout, ui.fin): |
|
52 | for dev in (ui.ferr, ui.fout, ui.fin): | |
49 | try: |
|
53 | try: | |
50 | try: |
|
54 | try: | |
@@ -53,13 +57,11 b' def termwidth(ui):' | |||||
53 | continue |
|
57 | continue | |
54 | if not os.isatty(fd): |
|
58 | if not os.isatty(fd): | |
55 | continue |
|
59 | continue | |
56 |
|
|
60 | if True: | |
57 |
arri = fcntl.ioctl(fd, |
|
61 | arri = fcntl.ioctl(fd, TIOCGWINSZ, '\0' * 8) | |
58 | width = array.array('h', arri)[1] |
|
62 | width = array.array('h', arri)[1] | |
59 | if width > 0: |
|
63 | if width > 0: | |
60 | return width |
|
64 | return width | |
61 | except AttributeError: |
|
|||
62 | pass |
|
|||
63 | except ValueError: |
|
65 | except ValueError: | |
64 | pass |
|
66 | pass | |
65 | except IOError as e: |
|
67 | except IOError as e: | |
@@ -67,6 +69,4 b' def termwidth(ui):' | |||||
67 | pass |
|
69 | pass | |
68 | else: |
|
70 | else: | |
69 | raise |
|
71 | raise | |
70 | except ImportError: |
|
|||
71 | pass |
|
|||
72 | return 80 |
|
72 | return 80 |
General Comments 0
You need to be logged in to leave comments.
Login now