[PATCH] Color command output using ui buffers

Matt Mackall mpm at selenic.com
Sat Dec 29 21:49:56 CST 2007


On Sat, 2007-12-29 at 17:21 -0600, kevin.christen at gmail.com wrote:
> # HG changeset patch
> # User Kevin Christen <kevin.christen at gmail.com>
> # Date 1198945152 21600
> # Node ID 7ebe8ea4d38e57bb27821ef5bd389662f20196f3
> # Parent  bc475d1f74caf65df21b267b5b9ab58770c3a903
> Color command output using ui buffers
> 
> diff -r bc475d1f74ca -r 7ebe8ea4d38e hgext/color.py
> --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
> +++ b/hgext/color.py	Sat Dec 29 10:19:12 2007 -0600
> @@ -0,0 +1,196 @@
> +# color.py color output for the status and qseries commands
> +#
> +# Copyright (C) 2007 Kevin Christen <kevin.christen at gmail.com>
> +#
> +# This program is free software: you can redistribute it and/or modify it
> +# under the terms of the GNU General Public License as published by the
> +# Free Software Foundation, either version 3 of the License, or (at your
> +# option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
> +# Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License along
> +# with this program.  If not, see <http://www.gnu.org/licenses/>.  This
> +# software may be used and distributed according to the terms of the GNU
> +# General Public License, incorporated herein by reference.
> +
> +'''add color output to the status and qseries commands
> +
> +This extension provides the cstatus command, which adds color to the output
> +of the status command to reflect file status, and the cqseries command,
> +which adds color to the output of the qseries command to reflect patch
> +status (applied, unapplied, missing).  Other effects in addition to color
> +are availble, like bold and underlined text.  Effects are rendered with the
> +ECMA-48 SGR control function (aka ANSI escape codes).  This module also
> +provides the render_text function, which can be used to add effects to any
> +text.

You might as well go all the way and replace the status and series
commands in the main command table (after you've saved a private
pointer), rather than introducing new commands. You should also probably
automatically disable color when the output is not to a tty.

-- 
Mathematics is the supreme nostalgia of our time.



More information about the Mercurial-devel mailing list