public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha•warpmail.net>
To: Johannes Sixt <j.sixt@viscovery•net>
Cc: Junio C Hamano <gitster@pobox•com>, git@vger•kernel.org
Subject: Re: [PATCH] Add a notice that only certain functions can print color escape codes
Date: Fri, 27 Nov 2009 10:22:12 +0100	[thread overview]
Message-ID: <4B0F9A44.7060706@drmicha.warpmail.net> (raw)
In-Reply-To: <4B0F82E1.80402@viscovery.net>

Johannes Sixt venit, vidit, dixit 27.11.2009 08:42:
> Junio C Hamano schrieb:
>> Johannes Sixt <j.sixt@viscovery•net> writes:
>>
>>> Like this?
>>
>> Yeah, and in addition to "puts", "write(2)" is also not supported, right?
> 
> Correct, good catch!
> 
> --- 8< ---
> From: Johannes Sixt <j6t@kdbg•org>
> Subject: [PATCH] Add a notice that only certain functions can print color escape codes
> 
> We emulate color escape codes on Windows by overriding printf, fprintf,
> and fputs. Warn users that these are the only functions that can be used
> to print them.
> 
> Signed-off-by: Johannes Sixt <j6t@kdbg•org>
> ---
>  color.h |    5 +++++
>  1 files changed, 5 insertions(+), 0 deletions(-)
> 
> diff --git a/color.h b/color.h
> index 7d8da6f..3cb4b7f 100644
> --- a/color.h
> +++ b/color.h
> @@ -4,6 +4,11 @@
>  /* "\033[1;38;5;2xx;48;5;2xxm\0" is 23 bytes */
>  #define COLOR_MAXLEN 24
> 
> +/*
> + * IMPORTANT: Due to the way these color codes are emulated on Windows,
> + * write them only using printf(), fprintf(), and fputs(). In particular,
> + * do not use puts() or write().

Nor putchar nor putc... but they're part of the puts family, of course.
More worthwhile then listing those negatives could be a hint on another
positive: color_fprintf and friends which are declared at the end of
color.h.

> + */
>  #define GIT_COLOR_NORMAL	""
>  #define GIT_COLOR_RESET		"\033[m"
>  #define GIT_COLOR_BOLD		"\033[1m"

  reply	other threads:[~2009-11-27  9:23 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-26 15:24 [RFC/PATCH 0/2] status -s: Use the same config as status Michael J Gruber
2009-11-26 15:24 ` [RFC/PATCH 1/2] status -s: respect the status.relativePaths option Michael J Gruber
2009-11-27  3:15   ` Junio C Hamano
2009-11-27  7:05   ` Jeff King
2009-11-26 15:24 ` [RFC/PATCH 2/2] status -s: obey color.status Michael J Gruber
2009-11-26 15:36   ` Johannes Sixt
2009-11-26 16:03     ` Michael J Gruber
2009-11-26 19:00     ` Junio C Hamano
2009-11-27  7:00       ` [PATCH] Add a notice that only certain functions can print color escape codes Johannes Sixt
2009-11-27  7:30         ` Junio C Hamano
2009-11-27  7:42           ` Johannes Sixt
2009-11-27  9:22             ` Michael J Gruber [this message]
2009-11-27  5:15   ` [RFC/PATCH 2/2] status -s: obey color.status Junio C Hamano
2009-11-27  9:17     ` Michael J Gruber

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=4B0F9A44.7060706@drmicha.warpmail.net \
    --to=git@drmicha$(echo .)warpmail.net \
    --cc=git@vger$(echo .)kernel.org \
    --cc=gitster@pobox$(echo .)com \
    --cc=j.sixt@viscovery$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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