comparison mercurial/ui.py @ 11324:cdf6d861b207

ui: add ui.formatted configuration variable and accessor function. This new configuration variable is similar in nature `ui.interactive', but applying to output instead of input. This allows as to support non-interactive sessions where formatted should be enabled, such as when using the pager extension. The variable itself is left undocumented; it is not intended for use outside Mercurial and its extensions.
author Dan Villiom Podlaski Christiansen <danchr@gmail.com>
date Mon, 07 Jun 2010 14:59:52 +0200
parents fcd06ecd4cb7
children 22a737306ba5
comparison
equal deleted inserted replaced
11323:d65b74106113 11324:cdf6d861b207
378 # usually those are non-interactive 378 # usually those are non-interactive
379 return False 379 return False
380 380
381 return i 381 return i
382 382
383 def formatted(self):
384 if self.plain():
385 return False
386
387 i = self.configbool("ui", "formatted", None)
388 if i is None:
389 try:
390 return sys.stdout.isatty()
391 except AttributeError:
392 # some environments replace stdout without implementing isatty
393 # usually those are non-interactive
394 return False
395
396 return i
397
383 def _readline(self, prompt=''): 398 def _readline(self, prompt=''):
384 if sys.stdin.isatty(): 399 if sys.stdin.isatty():
385 try: 400 try:
386 # magically add command line editing support, where 401 # magically add command line editing support, where
387 # available 402 # available