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