[PATCH] color: add support for terminfo-based attributes and color
dackze at gmail.com
Wed Aug 26 09:52:25 CDT 2009
On Aug 23, 2009, at 4:06 AM, Danek Duvall wrote:
> I really wanted to be able to use specific colors on my 256-color
> xterm, so
> I whipped up some changes to allow you to use any color terminfo can
> address for a terminal. The attached patch allows you to turn off
> to use the new code. It also allows you to define color names, like
> ecma48 = False
> color.pink = 207
> diff.hunk = pink
> If there's interest, I can make the appropriate changes to the module
> docstring, too.
I think this is a good idea. I thought about doing something like this
myself when I was trying to get my cdiff extension merged into color,
but I can't remember why we dropped the curses code or who talked me
into dropping it.
At any rate, I think allowing both curses and the hardcoded ECMA-48
codes to be used would be good. I have some questions, though:
- Is ecma48 the best name for the setting? I think it's a bit cryptic
to anyone who hasn't read up on terminal control sequences.
- Can effect_str() be moved out of render_effects()? It doesn't use
anything in the outer scope.
- Can the curses setup code be moved into its own function?
- Would there be any issues with enabling curses by default? I think
this would lead to more correct behavior: it would only output control
codes that the terminal supports (assuming the system's terminfo
database is correct).
Also, please do the following:
- Wrap long lines to 79 characters or less.
- Include the rationale for the patch in the commit message.
More information about the Mercurial-devel