Re: [PATCH 1/2] Added basic color support to git add --interactive

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

 



On Mon, Oct 22, 2007 at 04:32:44PM -0500, Dan Zwell wrote:

> +my ($use_color, $prompt_color, $header_color, $help_color);
> +my $color_config = qx(git config --get color.interactive);
> +if ($color_config=~/true|always/ || -t STDOUT && $color_config=~/auto/) {
> +	$use_color = "true";
> +        # Sane (visible) defaults:
> +        $prompt_color = "blue bold";
> +        $header_color = "bold";
> +        $help_color = "red bold";

Bad indentation?

> +sub print_colored {
> +	my $color = shift;
> +	my @strings = @_;
> +
> +	if ($use_color) {
> +		print Term::ANSIColor::color($color);
> +		print(@strings);
> +		print Term::ANSIColor::color("reset");
> +	} else {
> +		print @strings;
> +	}
> +}

This does nothing for embedded newlines in the strings, which means that
you can end up with ${COLOR}text\n${RESET}, which fouls up changed
backgrounds. See commit 50f575fc. Since the strings you are printing are
small, I don't see any problem with making a copy, using a regex to
insert the color coding, and printing that (I think I even posted
example code in a previous thread on this subject).

-Peff
-
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