All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Arjen Laarhoven <arjen@yaph.org>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Clean up use of ANSI color sequences
Date: Thu, 12 Feb 2009 15:03:21 -0800	[thread overview]
Message-ID: <7vy6wbi7gm.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1234471059-53625-1-git-send-email-arjen@yaph.org> (Arjen Laarhoven's message of "Thu, 12 Feb 2009 21:37:39 +0100")

Arjen Laarhoven <arjen@yaph.org> writes:

> diff --git a/color.h b/color.h
> index 5019df8..c4d2e53 100644
> --- a/color.h
> +++ b/color.h
> @@ -4,6 +4,16 @@
>  /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
>  #define COLOR_MAXLEN 24
>  
> +#define COLOR_NORMAL	""
> +#define COLOR_RESET	"\033[m"
> +#define COLOR_BOLD	"\033[1m"
> +#define COLOR_RED	"\033[31m"
> +#define COLOR_GREEN	"\033[32m"
> +#define COLOR_YELLOW	"\033[33m"
> +#define COLOR_BLUE	"\033[34m"
> +#define COLOR_CYAN	"\033[36m"
> +#define COLOR_BG_RED	"\033[41m"

Sounds like a very sane thing to do in principle, but the choice of
constant names are problematic.

 (1) There are COLOR_BRANCH_$category constants, that look very similar
     (they probably should be renamed to BRANCH_COLOR_$category). 

 (2) These are ANSI constants so it might be better to call them
     ANSI_COLOR_$physical_attributes, or GIT_COLOR_$physical_attributes.

     I actually prefer the latter because then later we can potentially
     redefine these macros with something like:

	#define GIT_COLOR_RED ti_setf(COLOR_RED)
	#define GIT_COLOR_BG_RED ti_setb(COLOR_RED)

     and write a set of small wrappers to terminfo to support non ANSI
     terminals without changing the rest of the code.  It is nicer to use
     GIT_COLOR_RED instead of COLOR_RED, because the latter are defined in
     ncurses.h like this:

        /* colors */
        #define COLOR_BLACK	0
        #define COLOR_RED	1
        #define COLOR_GREEN	2
        #define COLOR_YELLOW	3
        #define COLOR_BLUE	4
        #define COLOR_MAGENTA	5
        #define COLOR_CYAN	6
        #define COLOR_WHITE	7

  reply	other threads:[~2009-02-12 23:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-12 20:37 [PATCH] Clean up use of ANSI color sequences Arjen Laarhoven
2009-02-12 23:03 ` Junio C Hamano [this message]
2009-02-13 21:53   ` [PATCH 1/2] " Arjen Laarhoven
2009-02-13 21:53     ` [PATCH 2/2] builtin-branch.c: Rename branch category color names Arjen Laarhoven
2009-02-14  2:02     ` [PATCH 1/2] Clean up use of ANSI color sequences Junio C Hamano
2009-02-14  7:41       ` Arjen Laarhoven
2009-02-14  7:53         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vy6wbi7gm.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=arjen@yaph.org \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.