[PATCH] color: use ui.formatted() to test TTYness, not sys.stdout.isatty()

Christian Ebert blacktrash at gmx.net
Sun May 1 07:25:25 CDT 2011


* Brodie Rao on Sunday, May 01, 2011 at 14:04:06 +0200
> On May 1, 2011, at 1:28 PM, Christian Ebert wrote:
> 
>> * Brodie Rao on Sunday, May 01, 2011 at 12:14:24 +0200
>>> # HG changeset patch
>>> # User Brodie Rao <brodie at bitheap.org>
>>> # Date 1304244862 -7200
>>> # Node ID de9e9fed0d5ed6eb6f35ad7f387e3c447b4e22e8
>>> # Parent  3e9e02a41dfb0a85ec0968681e416d579ee875db
>>> color: use ui.formatted() to test TTYness, not sys.stdout.isatty()
>>> 
>>> This fixes the color extension not working with pager (broken in
>>> 877390020477). The pager extension already sets ui.formatted=True to
>>> allow this use case.
>> 
>> I still get control chars, unless I set color.mode = anssi:
>> 
>> ^Odiff --git a/hgext/color.py b/hgext/color.py^O
>> ^O--- a/hgext/color.py^O
>> ^O+++ b/hgext/color.py^O
>> [...]
> 
> My patch makes it so I can get colors inside my pager (less). I set my
> pager to "less -R" so it interprets the control codes.

Sure.

> Is the issue you're having that you don't want to see *any* color, or
> that you'd like color but you're getting the wrong control codes?

I want color, but no control chars.

>> Perhaps I missed an interim patch, it does not apply cleanly to
>> crew which I use for testing.
> 
> Pull from main.

xterm 270 (latest) seems to work now. But not within screen and
TERM=screen-256color (latest screen).

Terminal.app with Apple-shipped ncurses also displays control
chars (MacOS 10.5.8).

c
-- 
\black\trash movie           _COWBOY  CANOE  COMA_
            Ein deutscher Western/A German Western

--->> http://www.blacktrash.org/underdogma/ccc.php


More information about the Mercurial-devel mailing list