Re: [RFC] Colorization of log --graph

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 19, 2009 at 5:48 PM, Nanako Shiraishi <nanako3@xxxxxxxxxxx> wrote:
> Quoting Johannes Schindelin <Johannes.Schindelin@xxxxxx>:
>
>> I'd start like this:
>>
>>       enum color_name {
>>               COLOR_RESET,
>>               COLOR_RED,
>>               COLOR_GREEN,
>>               COLOR_YELLOW,
>>               COLOR_BLUE,
>>               COLOR_MAGENTA,
>>               COLOR_CYAN,
>>               COLOR_WHITE
>>       };
>
> Looking for "COLOR_RED" in the archive gives:
>
>  http://article.gmane.org/gmane.comp.version-control.git/109676
>

Duly noted.  Perhaps those #defines should be relocated to color.h?  If
we still wanted to provide a color_name type we could use
GIT_COLOR_NAME_RESET et al.  That would give us something like:

#define GIT_COLOR_NORMAL	""
#define GIT_COLOR_RESET		"\033[m"
#define GIT_COLOR_BOLD		"\033[1m"
#define GIT_COLOR_RED		"\033[31m"
#define GIT_COLOR_GREEN		"\033[32m"
#define GIT_COLOR_YELLOW	"\033[33m"
#define GIT_COLOR_BLUE		"\033[34m"
#define GIT_COLOR_CYAN		"\033[36m"
#define GIT_COLOR_BG_RED	"\033[41m"

enum color_name {
	GIT_COLOR_NAME_NORMAL
	GIT_COLOR_NAME_RESET,
	GIT_COLOR_NAME_RED,
	GIT_COLOR_NAME_GREEN,
	GIT_COLOR_NAME_YELLOW,
	GIT_COLOR_NAME_BLUE,
	GIT_COLOR_NAME_MAGENTA,
	GIT_COLOR_NAME_CYAN,
	GIT_COLOR_NAME_WHITE
	GIT_COLOR_NAME_BG_RED
};

/*
 * Map names to ANSI escape sequences.  Consider putting this in color.c
 * and providing color_name_get_ansi_code(enum color_name).
 */
const char* git_color_codes[] {
	GIT_COLOR_RESET,
	GIT_COLOR_BOLD,
	GIT_COLOR_RED,
	GIT_COLOR_GREEN,
	GIT_COLOR_YELLOW,
	GIT_COLOR_BLUE,
	GIT_COLOR_CYAN,
	GIT_COLOR_BG_RED,
};

That conveniently offers clients access to both the raw escape codes and
a clear type for storing/handling colors.

~Allan
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux