git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Tom ten Thij" <mail@tomtenthij.nl>
To: git@vger.kernel.org, gitster@pobox.com, rene.scharfe@lsrfire.ath.cx
Subject: [PATCH/RFC] More colors for pretty format: yellow, purple, cyan, white and black
Date: Thu, 24 Apr 2008 18:26:52 +0100	[thread overview]
Message-ID: <c19f1c910804241026q14f95af7qa0289018d08ac23a@mail.gmail.com> (raw)

Signed-off-by: Tom ten Thij <git@tomtenthij.nl>
---
Add support for other colors in pretty format the same way %Cred
works. I reordered the if
statements to start with the reset case and order the others by ansi
color code. Not sure if
I have to edit other files or how to do testing for a complete patch.

 Documentation/pretty-formats.txt |    5 +++++
 pretty.c                         |   21 ++++++++++++++++++---
 2 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/Documentation/pretty-formats.txt b/Documentation/pretty-formats.txt
index e8bea3e..c8631f8 100644
--- a/Documentation/pretty-formats.txt
+++ b/Documentation/pretty-formats.txt
@@ -120,6 +120,11 @@ The placeholders are:
 - '%Cred': switch color to red
 - '%Cgreen': switch color to green
 - '%Cblue': switch color to blue
+- '%Cyellow': switch color to yellow
+- '%Cpurple': switch color to purple
+- '%Ccyan': switch color to cyan
+- '%Cwhite': switch color to white
+- '%Cblack': switch color to black
 - '%Creset': reset color
 - '%m': left, right or boundary mark
 - '%n': newline
diff --git a/pretty.c b/pretty.c
index 6872932..b497008 100644
--- a/pretty.c
+++ b/pretty.c
@@ -471,17 +471,32 @@ static size_t format_commit_item(struct strbuf
*sb, const char *placeholder,
        /* these are independent of the commit */
        switch (placeholder[0]) {
        case 'C':
-               if (!prefixcmp(placeholder + 1, "red")) {
+               if (!prefixcmp(placeholder + 1, "reset")) {
+                       strbuf_addstr(sb, "\033[m");
+                       return 6;
+               } else if (!prefixcmp(placeholder + 1, "black")) {
+                       strbuf_addstr(sb, "\033[30m");
+                       return 6;
+               } else if (!prefixcmp(placeholder + 1, "red")) {
                        strbuf_addstr(sb, "\033[31m");
                        return 4;
                } else if (!prefixcmp(placeholder + 1, "green")) {
                        strbuf_addstr(sb, "\033[32m");
                        return 6;
+               } else if (!prefixcmp(placeholder + 1, "yellow")) {
+                       strbuf_addstr(sb, "\033[33m");
+                       return 7;
                } else if (!prefixcmp(placeholder + 1, "blue")) {
                        strbuf_addstr(sb, "\033[34m");
                        return 5;
-               } else if (!prefixcmp(placeholder + 1, "reset")) {
-                       strbuf_addstr(sb, "\033[m");
+               } else if (!prefixcmp(placeholder + 1, "purple")) {
+                       strbuf_addstr(sb, "\033[35m");
+                       return 7;
+               } else if (!prefixcmp(placeholder + 1, "cyan")) {
+                       strbuf_addstr(sb, "\033[36m");
+                       return 5;
+               } else if (!prefixcmp(placeholder + 1, "white")) {
+                       strbuf_addstr(sb, "\033[37m");
                        return 6;
                } else
                        return 0;
-- 
1.5.4.4

             reply	other threads:[~2008-04-24 17:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-24 17:26 Tom ten Thij [this message]
2008-04-25 20:42 ` [PATCH/RFC] More colors for pretty format: yellow, purple, cyan, white and black René Scharfe

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=c19f1c910804241026q14f95af7qa0289018d08ac23a@mail.gmail.com \
    --to=mail@tomtenthij.nl \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).