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

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

 



El 23/10/2007, a las 6:03, Jeff King escribió:

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).

I did too, where you add a third, optional "trailer" parameter to the function where you pass the newline if there is one (following the style of the functions in color.c). Pasting it below.

Having said that, I think this kind of function belongs in Git.pm, and the dependency on Term::ANSIColor should be replaced with dependency-free code that generates the colors itself; this should be easy because the number of possible colors is small, Git thus far only uses a subset of the possible ANSI colors, and the C code for doing it is already there in color.c and just needs to be translated into Perl.

sub print_ansi_color {
	my $color = shift;
	my $string = shift;
	my $trailer = shift;
	if ($use_color) {
		print Term::ANSIColor::color($color), $string,
		    Term::ANSIColor::color('clear');
	} else {
		print $string;
	}
	if ($trailer) {
		print $trailer;
	}
}

Cheers,
Wincent



-
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