Show More
@@ -149,7 +149,7 b' def churn(ui, repo, *pats, **opts):' | |||||
149 | maxcount = float(max(sum(v) for k, v in rate)) or 1.0 |
|
149 | maxcount = float(max(sum(v) for k, v in rate)) or 1.0 | |
150 | maxname = max(len(k) for k, v in rate) |
|
150 | maxname = max(len(k) for k, v in rate) | |
151 |
|
151 | |||
152 |
ttywidth = u |
|
152 | ttywidth = ui.termwidth() | |
153 | ui.debug("assuming %i character terminal\n" % ttywidth) |
|
153 | ui.debug("assuming %i character terminal\n" % ttywidth) | |
154 | width = ttywidth - maxname - 2 - 2 - 2 |
|
154 | width = ttywidth - maxname - 2 - 2 - 2 | |
155 |
|
155 |
@@ -1437,7 +1437,7 b' class queue(object):' | |||||
1437 | ph = patchheader(self.join(patchname), self.plainmode) |
|
1437 | ph = patchheader(self.join(patchname), self.plainmode) | |
1438 | msg = ph.message and ph.message[0] or '' |
|
1438 | msg = ph.message and ph.message[0] or '' | |
1439 | if self.ui.formatted(): |
|
1439 | if self.ui.formatted(): | |
1440 |
width = u |
|
1440 | width = self.ui.termwidth() - len(pfx) - len(patchname) - 2 | |
1441 | if width > 0: |
|
1441 | if width > 0: | |
1442 | msg = util.ellipsis(msg, width) |
|
1442 | msg = util.ellipsis(msg, width) | |
1443 | else: |
|
1443 | else: |
@@ -156,7 +156,7 b' class progbar(object):' | |||||
156 | sys.stderr.flush() |
|
156 | sys.stderr.flush() | |
157 |
|
157 | |||
158 | def width(self): |
|
158 | def width(self): | |
159 |
tw = u |
|
159 | tw = self.ui.termwidth() | |
160 | return min(int(self.ui.config('progress', 'width', default=tw)), tw) |
|
160 | return min(int(self.ui.config('progress', 'width', default=tw)), tw) | |
161 |
|
161 | |||
162 | def progress(self, topic, pos, item='', unit='', total=None): |
|
162 | def progress(self, topic, pos, item='', unit='', total=None): |
@@ -706,7 +706,7 b' def diffordiffstat(ui, repo, diffopts, n' | |||||
706 | diffopts = diffopts.copy(context=0) |
|
706 | diffopts = diffopts.copy(context=0) | |
707 | width = 80 |
|
707 | width = 80 | |
708 | if not ui.plain(): |
|
708 | if not ui.plain(): | |
709 |
width = u |
|
709 | width = ui.termwidth() | |
710 | chunks = patch.diff(repo, node1, node2, match, changes, diffopts, |
|
710 | chunks = patch.diff(repo, node1, node2, match, changes, diffopts, | |
711 | prefix=prefix) |
|
711 | prefix=prefix) | |
712 | for chunk, label in patch.diffstatui(util.iterlines(chunks), |
|
712 | for chunk, label in patch.diffstatui(util.iterlines(chunks), |
@@ -1834,7 +1834,7 b' def help_(ui, name=None, with_version=Fa' | |||||
1834 | Returns 0 if successful. |
|
1834 | Returns 0 if successful. | |
1835 | """ |
|
1835 | """ | |
1836 | option_lists = [] |
|
1836 | option_lists = [] | |
1837 |
textwidth = u |
|
1837 | textwidth = ui.termwidth() - 2 | |
1838 |
|
1838 | |||
1839 | def addglobalopts(aliases): |
|
1839 | def addglobalopts(aliases): | |
1840 | if ui.verbose: |
|
1840 | if ui.verbose: |
@@ -272,7 +272,7 b' def spawndetached(args):' | |||||
272 | def gethgcmd(): |
|
272 | def gethgcmd(): | |
273 | return sys.argv[:1] |
|
273 | return sys.argv[:1] | |
274 |
|
274 | |||
275 |
def termwidth |
|
275 | def termwidth(): | |
276 | try: |
|
276 | try: | |
277 | import termios, array, fcntl |
|
277 | import termios, array, fcntl | |
278 | for dev in (sys.stderr, sys.stdout, sys.stdin): |
|
278 | for dev in (sys.stderr, sys.stdout, sys.stdin): |
@@ -402,6 +402,16 b' class ui(object):' | |||||
402 |
|
402 | |||
403 | return i |
|
403 | return i | |
404 |
|
404 | |||
|
405 | def termwidth(self): | |||
|
406 | '''how wide is the terminal in columns? | |||
|
407 | ''' | |||
|
408 | if 'COLUMNS' in os.environ: | |||
|
409 | try: | |||
|
410 | return int(os.environ['COLUMNS']) | |||
|
411 | except ValueError: | |||
|
412 | pass | |||
|
413 | return util.termwidth() | |||
|
414 | ||||
405 | def formatted(self): |
|
415 | def formatted(self): | |
406 | '''should formatted output be used? |
|
416 | '''should formatted output be used? | |
407 |
|
417 |
@@ -1393,14 +1393,6 b' except NameError:' | |||||
1393 | return False |
|
1393 | return False | |
1394 | return True |
|
1394 | return True | |
1395 |
|
1395 | |||
1396 | def termwidth(): |
|
|||
1397 | if 'COLUMNS' in os.environ: |
|
|||
1398 | try: |
|
|||
1399 | return int(os.environ['COLUMNS']) |
|
|||
1400 | except ValueError: |
|
|||
1401 | pass |
|
|||
1402 | return termwidth_() |
|
|||
1403 |
|
||||
1404 | def interpolate(prefix, mapping, s, fn=None): |
|
1396 | def interpolate(prefix, mapping, s, fn=None): | |
1405 | """Return the result of interpolating items in the mapping into string s. |
|
1397 | """Return the result of interpolating items in the mapping into string s. | |
1406 |
|
1398 |
@@ -181,7 +181,7 b' def hidewindow():' | |||||
181 | pid = win32process.GetCurrentProcessId() |
|
181 | pid = win32process.GetCurrentProcessId() | |
182 | win32gui.EnumWindows(callback, pid) |
|
182 | win32gui.EnumWindows(callback, pid) | |
183 |
|
183 | |||
184 |
def termwidth |
|
184 | def termwidth(): | |
185 | try: |
|
185 | try: | |
186 | # Query stderr to avoid problems with redirections |
|
186 | # Query stderr to avoid problems with redirections | |
187 | screenbuf = win32console.GetStdHandle(win32console.STD_ERROR_HANDLE) |
|
187 | screenbuf = win32console.GetStdHandle(win32console.STD_ERROR_HANDLE) |
@@ -356,7 +356,7 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 |
|
359 | def termwidth(): | |
360 | # cmd.exe does not handle CR like a unix console, the CR is |
|
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 |
|
361 | # counted in the line length. On 80 columns consoles, if 80 | |
362 | # characters are written, the following CR won't apply on the |
|
362 | # characters are written, the following CR won't apply on the |
General Comments 0
You need to be logged in to leave comments.
Login now