Show More
@@ -265,3 +265,27 b' def spawndetached(args):' | |||||
265 |
|
265 | |||
266 | def gethgcmd(): |
|
266 | def gethgcmd(): | |
267 | return sys.argv[:1] |
|
267 | return sys.argv[:1] | |
|
268 | ||||
|
269 | def termwidth_(): | |||
|
270 | try: | |||
|
271 | import termios, array, fcntl | |||
|
272 | for dev in (sys.stderr, sys.stdout, sys.stdin): | |||
|
273 | try: | |||
|
274 | try: | |||
|
275 | fd = dev.fileno() | |||
|
276 | except AttributeError: | |||
|
277 | continue | |||
|
278 | if not os.isatty(fd): | |||
|
279 | continue | |||
|
280 | arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) | |||
|
281 | return array.array('h', arri)[1] | |||
|
282 | except ValueError: | |||
|
283 | pass | |||
|
284 | except IOError, e: | |||
|
285 | if e[0] == errno.EINVAL: | |||
|
286 | pass | |||
|
287 | else: | |||
|
288 | raise | |||
|
289 | except ImportError: | |||
|
290 | pass | |||
|
291 | return 80 |
@@ -1252,35 +1252,6 b' def uirepr(s):' | |||||
1252 | # Avoid double backslash in Windows path repr() |
|
1252 | # Avoid double backslash in Windows path repr() | |
1253 | return repr(s).replace('\\\\', '\\') |
|
1253 | return repr(s).replace('\\\\', '\\') | |
1254 |
|
1254 | |||
1255 | def termwidth(): |
|
|||
1256 | if 'COLUMNS' in os.environ: |
|
|||
1257 | try: |
|
|||
1258 | return int(os.environ['COLUMNS']) |
|
|||
1259 | except ValueError: |
|
|||
1260 | pass |
|
|||
1261 | try: |
|
|||
1262 | import termios, array, fcntl |
|
|||
1263 | for dev in (sys.stderr, sys.stdout, sys.stdin): |
|
|||
1264 | try: |
|
|||
1265 | try: |
|
|||
1266 | fd = dev.fileno() |
|
|||
1267 | except AttributeError: |
|
|||
1268 | continue |
|
|||
1269 | if not os.isatty(fd): |
|
|||
1270 | continue |
|
|||
1271 | arri = fcntl.ioctl(fd, termios.TIOCGWINSZ, '\0' * 8) |
|
|||
1272 | return array.array('h', arri)[1] |
|
|||
1273 | except ValueError: |
|
|||
1274 | pass |
|
|||
1275 | except IOError, e: |
|
|||
1276 | if e[0] == errno.EINVAL: |
|
|||
1277 | pass |
|
|||
1278 | else: |
|
|||
1279 | raise |
|
|||
1280 | except ImportError: |
|
|||
1281 | pass |
|
|||
1282 | return 80 |
|
|||
1283 |
|
||||
1284 | def wrap(line, hangindent, width=None): |
|
1255 | def wrap(line, hangindent, width=None): | |
1285 | if width is None: |
|
1256 | if width is None: | |
1286 | width = termwidth() - 2 |
|
1257 | width = termwidth() - 2 | |
@@ -1364,3 +1335,11 b' except NameError:' | |||||
1364 | if not i: |
|
1335 | if not i: | |
1365 | return False |
|
1336 | return False | |
1366 | return True |
|
1337 | return True | |
|
1338 | ||||
|
1339 | def termwidth(): | |||
|
1340 | if 'COLUMNS' in os.environ: | |||
|
1341 | try: | |||
|
1342 | return int(os.environ['COLUMNS']) | |||
|
1343 | except ValueError: | |||
|
1344 | pass | |||
|
1345 | return termwidth_() |
@@ -356,6 +356,13 b' def spawndetached(args):' | |||||
356 | def gethgcmd(): |
|
356 | def gethgcmd(): | |
357 | return [sys.executable] + sys.argv[:1] |
|
357 | return [sys.executable] + sys.argv[:1] | |
358 |
|
358 | |||
|
359 | def termwidth_(): | |||
|
360 | # cmd.exe does not handle CR like a unix console, the CR is | |||
|
361 | # counted in the line length. On 80 columns consoles, if 80 | |||
|
362 | # characters are written, the following CR won't apply on the | |||
|
363 | # current line but on the new one. Keep room for it. | |||
|
364 | return 79 | |||
|
365 | ||||
359 | try: |
|
366 | try: | |
360 | # override functions with win32 versions if possible |
|
367 | # override functions with win32 versions if possible | |
361 | from win32 import * |
|
368 | from win32 import * |
General Comments 0
You need to be logged in to leave comments.
Login now