This seems to work with or without attributes. We'll deal with
256-color terminal colors when/if somebody cares for it, but the
usual 16 ought to be more than enough.
+my $COLOR = qr/(?:bright)?
+ (?:normal|black|red|green|yellow|blue|magenta|cyan|white)/x;
+
- my ($self, $slot) = @_; # $_[2] = buffer
+ my ($self, $slot, $buf) = @_;
my $val = $self->{"color.$slot"} //=
$self->{-leicfg}->{"color.$slot"} //
$self->{-gitcfg}->{"color.diff.$slot"} //
my $val = $self->{"color.$slot"} //=
$self->{-leicfg}->{"color.$slot"} //
$self->{-gitcfg}->{"color.diff.$slot"} //
$DEFAULT_COLOR{$slot};
$val = $val->[-1] if ref($val) eq 'ARRAY';
if (defined $val) {
$DEFAULT_COLOR{$slot};
$val = $val->[-1] if ref($val) eq 'ARRAY';
if (defined $val) {
# git doesn't use "_", Term::ANSIColor does
# git doesn't use "_", Term::ANSIColor does
- $val =~ s/\Abright([^_])/bright_$1/i;
- ${$self->{obuf}} .= Term::ANSIColor::colored($_[2], lc $val);
+ $val =~ s/\Abright([^_])/bright_$1/ig;
+
+ # git: "green black" => T::A: "green on_black"
+ $val =~ s/($COLOR)(.+?)($COLOR)/$1$2on_$3/;
+
+ # FIXME: convert git #XXXXXX to T::A-compatible colors
+ # for 256-color terminals
+
+ ${$self->{obuf}} .= colored($buf, $val);
- ${$self->{obuf}} .= $_[2];
+ ${$self->{obuf}} .= $buf;