[PATCH] color: use ui.formatted() to test TTYness, not sys.stdout.isatty()
Christian Ebert
blacktrash at gmx.net
Tue May 3 03:21:24 CDT 2011
* Christian Ebert on Tuesday, May 03, 2011 at 09:19:07 +0100
> * Christian Ebert on Sunday, May 01, 2011 at 13:25:25 +0100
>> * 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).
>
> Played around some more. Seems it depends on the value of $TERM.
> Here are the results for the $TERM values I mostly use:
>
> xterm-256color: ok
> screen-256color: control chars
> nsterm-16color: control chars
>
> Aside: nsterm-* is recommended for Terminal.app on MacOS X, even
> though the default is usually something like xterm-color iirc.
>
> As I notice no performance problems with color.mode=ansi, so I'm
> gonna stick to that. Still others might encounter this, depending
> on their $TERM setting.
Addendum: I tested with a completely empty ~/.lesskey and the
minimal setting of pager.pager = less -R
c
--
\black\trash movie _MORALISK ANSTALT_
"Nix verstanden."
--->> http://www.blacktrash.org/underdogma/moraliskanstalt.php
More information about the Mercurial-devel
mailing list